6 Replies Latest reply on Mar 30, 2014 10:59 PM by bigtom

    Applescript and Filemaker

    bigtom

      I need a script that exports container images and then loads those images into iPhoto with a set album name and deleting the temporary image export files.

      The export works fine. Setting the album name in iPhoto works fine. The import into iPhoto is not working. Get one image in and then the errors.

       

      I am giving this calculated applescript a try but I am getting errors.

      "Can’t make «class docf» "999999-10.jpg" of «class cfol» "image" of «class cfol» "Desktop" of «class cfol» "user" of «class cfol» "Users" of «class sdsk» of application "Finder" into type alias."

      "Unknown Error: -1700."

       

      Honestly there is nothing good I could find about the proper syntax for calculated applescripts in Filemaker. If someone can recommend a refference I would be happy to check it out.

       

      I pieced this together from bits of info I found on the web. I guess I could try not using a calculated script. I do not know too much about applescript itself so that does not help. Same thing happens not importing as alias.

       

       

      List(

      "set theFolder to " & Quote ( $path );

      "set albumName to " & Quote ( $SKU );

      "tell application " & Quote ( "Finder" ) & " to set theFiles to files of folder theFolder";

      "tell application " & Quote ( "iPhoto" ) & " to if not (exists album albumName) then new album name albumName";

      "repeat with oneFile in theFiles";

      "tell application " & Quote ( "iPhoto" );

      "import from (oneFile as alias) to album albumName";

      "repeat while importing";

      "delay 1";

      "end repeat";

      "end tell";

      "tell application " & Quote ( "Finder" );

      "delete files of folder theFolder";

      "end tell";

      "end"

      )

       

       

      Any info on how this works would be appreciated.

        • 1. Re: Applescript and Filemaker
          BruceRobertson

          You might begin by creating a simple example file and posting it here.

          • 2. Re: Applescript and Filemaker
            gdurniak

            It seems the problem line is  "import from (oneFile as alias) to album albumName";

             

            Try to make it work in Applescript Editor first

             

            Then move it to Filemaker

             

            greg

             

            > I am giving this calculated applescript a try but I am getting errors.

            "Can’t make «class docf» "999999-10.jpg" of «class cfol» "image" of «class cfol» "Desktop" of «class cfol» "user" of «class cfol» "Users" of «class sdsk» of application "Finder" into type alias."


            • 3. Re: Applescript and Filemaker
              bigtom

              Had it working in script editor, but still had an issue in the calculated script. Got it solved by calling the FM variables directly instead of setting an AS variable with a FM variable. Though that should have worked.

               

              Works now. But still wish there was more info on this in general.

              • 4. Re: Applescript and Filemaker
                gdurniak

                I have not found one good reference, but a Google search will offer hundreds of examples

                 

                My biggest problems are with Applescript itself

                 

                Keep in mind that you must first "Tell Filemaker" to set the variables ( and Globals are easier to deal with )

                 

                Then "Tell Finder" to perform the action

                 

                greg

                 

                 

                > Had it working in script editor, but still had an issue in the calculated script. Got it solved by calling the FM variables directly instead of setting an AS variable with a FM variable. Though that should have worked.

                 

                Works now. But still wish there was more info on this in general.

                • 5. Re: Applescript and Filemaker
                  BruceRobertson

                  bigtom: That's why posting a file here would be much more useful.

                   

                  We cannot see how you are handling or mishandling various parts of your script.

                  If there is a file to work with we can modify it to provide working methods and demonstrate variations.

                   

                  As for "tell FileMaker", no you do NOT need to use that construct within a FileMaker perform applescript statement.

                   

                  Scripting Finder is mostly not necessary and is problematic.

                  Applescript supports the "do shell script" construction and that can be used for file handling, creating directories, etc.

                  • 6. Re: Applescript and Filemaker
                    bigtom

                    Bruce, part of my fix was to remove everything from the AS that dealt with Finder. I was mid example file when I had an idea of how to make it work. I still may provide an example as the way I expected FIlemaker to interact with the AS did not happen. I certainly would learn somehting when I do.