Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Create folder in Mac OS X with field variable, AppleScript

Featured Replies

Hi,

I'm a pure newbie to Mac (Mac OS X 10.8.3) and trying to a folder based on field data under a fixed path, but without any luck:

set dirName to cell "fk_person_id" of current record 

set targetPath to quoted form of ("/Volumes/Macintosh/cluster5/medistic/media/" & dirName) 

do shell script "mkdir -p " & targetPath

The above returns the below errors:
Object not found.
Unknown error: -1728.

What is wrong with my script, please help...

 

Do you want to perform this from within FileMaker? If so, you can use a direct field reference: 

List (
  "set dirName to " & YourTable::fk_person_id ; // note that this now is a FileMaker field reference  
  "set targetPath to quoted form of ( \"/Volumes/Macintosh/cluster5/medistic/media/\" & dirName )" ;
  "do shell script \"mkdir -p\" & targetPath"
)

Test the result of that expression (not this Filemaker code) in the (Apple)Script Editor.

Edited by eos

  • Author
set dirName to "person_pk2fk_media::fk_person_id"
set targetPath to quoted form of ("/Users/cluster5/medistic/media/" & dirNAme
do shell script "mkdir -p " & targetPath

returns a folder as below (rather than the fk_person_id which should be 10001) :

person_pk2fk_media//fk_person_id

 

Any advice how to fix ?

Edited by mastichis

Any advice how to fix ?

​Read more carefully?

  • Author

Well, if I'm correct I'm trying to run this in a Native AppleScript -to create a new directory. I dont even know if this is the correct approach as I'm not even a Mac user, I'm a Windows user, and all this doesn't really make sense to me.

The folder "person_pk2fk_media//fk_person_id" is created when script is run.

What should I change to create the correct folder name taken from the field "person_pk2fk_media::fk_person_id" ?

 

Well, if I'm correct I'm trying to run this in a Native AppleScript

​This is a Filemaker calculation; you need to specify the code as the calculation for the “Calculated AppleScript” option.

As noted before: try to evaluate this in the Data Viewer (in the correct context, i.e. person_pk2fk_media) and test the result in the AppleScript Editor.

As an aside: 

set dirName to cell "fk_person_id" of current record 

requires that the field "fk_person_id" be present on the current layout - otherwise you will get the error mentioned in the original post.

  • Author

Ok, that made some sense -didn't pick it up at first. I got it working, putting it in the "Calculated AppleScript" as you said EOS and it worked!

Final working code:

List(
  "set dirName to " & person_pk2fk_media::fk_person_id ;
  "set targetPath to quoted form of (\"/Users/cluster5/medistic/media/\" & dirName)" ;
  "do shell script \"mkdir -p \" & targetPath"
)

Result:

/Users/cluster5/medistic/media/10001

 

Thank you all for helping out!

You could also use Base Elements Plugin to create folders at a path plus it will work on mac and windows

http://www.goya.com.au/baseelements/plugin

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.