4 Replies Latest reply on Nov 9, 2009 12:23 PM by maloney

    AppleScript - duplicating folder, renaming it with field data

    maloney

      Title

      AppleScript - duplicating folder, renaming it with field data

      Post

      Hi,

       

      I would like to setup a button which starts an AppleScript.

      The Applescript should duplicate a predefined folder and rename it with something from a specific field.

       

      Can someone please help.

       

      Thanks. 

        • 1. Re: AppleScript - duplicating folder, renaming it with field data
          david_lalonde@d-cogit.ca
            

          This is definitely off-topic.

           

          To learn AppleScript, open the AppleScript editor. In the help menu, select to show the AppleScript Language Guide. This is a well written, clear and concise manual.

           

          It will not, however, tell you how to write programs. If you need that, you can pick up one of the many programming teaching books available through book stores or libraries. One of my favourites is The C Programming Language, by Kernighan and Ritchie, the originators of the C language. This book is very concise, very in depth and is written for both beginners and experts. It does assume you have a good grasp of procedural logic.

           

          As for the specifics of AppleScript in FileMaker Pro...

           

          If you want to include field variables in your AppleScript script, you will need to write a calculation that mixes literals and fields similar to: "My name is " & myTable::nameField & "." The only "pain" you will have will be to deal the the amount of quotes that appear in typical AppleScript scripts. These will always need to be escaped with a backslash character. It will make reading the script a bit of a challenge, and if you forget a quote or forget to escape a quote, finding the error will be the source of the "pain" I mentioned.

           

          Also, you would normally write "Tell application "FileMaker Pro"" in AppleScript. This is not always so in scripts you write in FileMaker Pro. I have yet to know when it needs to be written and when it does not. Debugging is usually where I find out. 

          • 2. Re: AppleScript - duplicating folder, renaming it with field data
            maloney
              

            Hi David,

             

            thank you very much for your help.

             

            To be honest I am not sure if AppleScript is the right choice for my problem.

             

            Is there maybe another way to duplicate and rename a folder from the Filemaker interface.

             

            Based on the project number and name of a record in Filemaker I would like to generate a project folder on our server. 

            Right now we have a dummy-folder with specific subfolders which we duplicate and rename manually.

             

             

            Maloney 

            • 3. Re: AppleScript - duplicating folder, renaming it with field data
              david_lalonde@d-cogit.ca
                

              This is definitely out of FileMaker Pro's capability. AppleScript is a great approach to implementing this within FileMaker Pro.

               

              I forgot to add in my original post, you might want to deal with a consultant for training, coaching or even for development.

              • 4. Re: AppleScript - duplicating folder, renaming it with field data
                maloney
                  

                 Ok, my script is working out of AppleScript Editor:

                 

                tell application "Finder"
                duplicate folder "folder_name" of disk "disk_name" with replacing
                set name of folder "folder_name copy" of disk "disk_name" to "field_name"
                end tell 

                 

                It works also in Filemaker's  "Perform Applescript" options as native AppleScript.
                I think it has to be a calculated AppleScript in Filemaker.
                 
                How do I have to "convert" or write the AppleScript in Filemaker's "Specify Calculation" window?
                 
                There is always the message: The specified table cannot be found.