Brian Dunning's FileMaker Custom Functions

OpenFolder ( path ; name )

A custom function to create and open a folder on the Mac OS X operating system.

  Average rating: 3.9 (38 votes) Log in to vote

Matt Petrowsky   Matt Petrowsky
ISO Productions, Inc.
http://www.filemakermagazine.com

Share on Facebook Share on Twitter

  Sample input:
Let(
[
f = folderName;
mypath = "/Volumes" & Substitute ( Get ( FilePath ) ; ["file:" ; ""]; [ Get ( FileName ) & ".fp7" ; ""] )
];

OpenFolder ( mypath; f )

)
  Sample output:
do shell script "path="/Volumes/Hard Drive/Users/me/Desktop/New Folder"; if [ ! -d "$path" ];then mkdir "$path"; open "$path"; else open "$path"; fi"

New folder (relative to the FMP file) is created and opened if it does not exist. Otherwise the folder is simply opened.

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

NOTE: MACINTOSH ONLY FUNCTION

This function can be used to generate the AppleScript code needed to create and open a folder on Mac OS X. Simply supply a proper POSIX path and the name of the folder you want. It may not work with ~ designations so supply a full absolute path.

To use just make a script with Perform AppleScript and point to the calculation.

 

Comments

abonino   abonino, CH Bern
Nov 16, 2011
FMPA tell error
 
Rouel Fernandez   Rouel Fernandez, Mountain View, Ca
Feb 9, 2012
The following: "\"" in the function produces an error: List usage is not allowed in this calculation.

Using FM 11 Adv.
 
G. Dyson   G. Dyson, Lausanne, CH
Jun 9, 2012
No-one has a solution to the error message given above?
 
Lars   Lars, Berlin
Oct 30, 2012
How can this used in a script step?
 
Johan   Johan, Sweden
Aug 31, 2013
This problem seems to remain still:

The following: "\"" in the function produces an error: List usage is not allowed in this calculation.

How can it be avoided?
 
Charles Houghton-Webb   Charles Houghton-Webb, France
Jan 7, 2014
Since Filemaker 7 :
Substitute ( cmd ; """ ; "\"" )
does not work.
You have to unescape everything, including the unescape character !
So you would write :
Substitute ( cmd ; "\"" ; "\\\"" )

That should do the trick here ;-)
 
Charles Houghton-Webb   Charles Houghton-Webb, France
Jan 7, 2014
My above comment is true, but won't work here. The function needs to b re-written.
The quoted forms are unnecessary, and you need single quotes on the path, rather than double ones. This should do the trick… at least it does for me ;-)

Let(
[
f = name;
mypath = path & name ;
pathVar = "$path" ;
sh = "if [ ! -d " & pathVar & " ];then mkdir " & pathVar & "; open " & pathVar & "; else open " & pathVar & "; fi";
cmd = "path='" & mypath & "'; " & sh; // RAW SHELL SCRIPT CODE
applescript = "do shell script \"" & cmd & "\"" // APPLESCRIPT FORMATTED PATH
];

applescript

)
 
Charles Houghton-Webb   Charles Houghton-Webb, France
Jan 7, 2014
Oooops !! I forgot to delete the
f = name;
line, which serves absolutely no purpose whatever.
You can delete without problem ;-)
 

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: