Create a new folder from FileMaker with AppleScript

I have a button on a FileMaker form that I want to use to create a new folder within the documents/jobhunt folder. This is one of those things that you’d think would be easy to accomplish, but there is no command within FileMaker scripting to do it. One solution is to use the FileMaker script step [Perform Applescript], and execute the following Applescript.  Note that the dialog which allows you type in a folder name is an AppleScript dialog not a FileMaker dialog. 

What is happening within the script, is the following: 
1. Displays a dialog to choose a folder name














2. Copy the folder name to a variable text_returned
3. Assign the path of the user’s Documents folder to the variable p.  
/Users/lkeyes/Documents
4. Append the existing JobHunt folder to the path 
/Users/lkeyes/Documents/Job Hunt
5. Create a new folder within the “Job Hunt” folder with the name myfolder.  

Here is the code from the FileMaker Script:  

Perform AppleScript [ Native AppleScript: display dialog “Enter a folder name for your job:” default answer “” buttons {“OK”, “Cancel”} default button 1
copy the result as list to {text_returned, button_pressed}
set p to path to documents folder as string set p to p & “Job Hunt:”
tell application “Finder”
make new folder at p with properties {name:text_returned}

end tell ] 


Here is the code from the Applescript Editor: 

display dialog “Enter a folder name for your job:” default answer “” buttons {“OK”, “Cancel”} default button 1
copy the result as list to {text_returned, button_pressed}
set p to path to documents folder as string
set p to p & “Job Hunt:”
tell application “Finder”
make new folder at p with properties {name:text_returned}
end tell
Now, I have naturally received advice to use a FileMaker plug-in, which makes this a lot easier. 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s