Brian Dunning's FileMaker Custom Functions

makefolder ( new_folder ; pathTo )

Use the perform applescript script step with this function to perform new folder creation with applescript..

  Average rating: 4.0 (37 votes) Log in to vote

Kenneth Durrum   Kenneth Durrum - Show more from this author
Released Solutions
https://releasedsolutions.net

Share on Facebook Share on Twitter

  Sample input:
makefolder ( myfolder , mypath )
  Sample output:
tell application "Finder"
if not (exists folder "yourFolder" in alias "your:path:to:" ) then
make new folder in folder "your:path:to:" with properties {name:"yourFolder"}
end if
end tell

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Use the perform applescript script step with this function to perform folder creation action.

 

Comments

Richard Hyams   Richard Hyams, New York
Apr 13, 2009
Is something that uses apple script really a filemaker custom function?
 
Lorne Walton   Lorne Walton, Maple Ridge, BC, Canada
Apr 17, 2009
My answer: only if you use a Mac.

These script steps:

Set Variable ( $path ; Get ( DocumentsPath ) )
Perform AppleScript ( makefolder ( "vcard" ; $path ) )

generate an error -43 and the comment that my Documents folder cannot be found. It is in fact, right where it is intended to be.

The folder "vcards" is not created.
 
Craig Williams   Craig Williams, Monument, CO
May 3, 2009
The reason Get ( DocumentsPath ) is failing in the code above is because it returns a POSIX path and Finder needs a HFS path ( colon separated).

"HardDrive:Users:user_name:Documents:"

Make that adjustment and it should work fine.
 
Lorne Walton   Lorne Walton, Maple Ridge, BC, Canada
May 4, 2009
Tried that. Didn't work. This change to the CF worked:

"
set ASPath to \"" & pathTo & "\" ¶
tell application \"Finder\" ¶

if not (exists folder \"" & new_folder & "\"" & " in alias ASPath ) then ¶
make new folder in folder " & "\""& pathTo & "\" "& " with properties {name:" & "\"" & new_folder & "\"} ¶
end if ¶
end tell

"
 
Jack James   Jack James, London
May 6, 2009
It's bad practice to call Finder to perform operations such as this.
Instead you should use:

tell application " & Quote("System Events") &"¶
make new folder at end of pathTo¶
end tell¶
 
James Ducker   James Ducker, Swindon UK
Jan 22, 2010
I find it more reliable -- and quicker -- to call a shell script:

set variable $AppleScript to

"do shell script " & quote ( "mkdir /Users/jamesducker/Desktop/whatever/" )


perform applescript $AppleScript
 
Juan Cardona   Juan Cardona, Palma, Spain
Oct 22, 2010
James Ducker,

Perfect -SIMPLE- solution
 
Paulo   Paulo, Florianopolis, Brasil
Feb 25, 2018
James Ducker,

Perfect, but...

how can i mkdir with space in its name?
 
Paulo   Paulo, Florianopolis, Brasil
Feb 25, 2018
James Ducker,

Perfect, but...

how can i mkdir with space in its name?
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: