Jump to content
Server Maintenance This Week. ×

Create folder in Mac OS X with field variable, AppleScript


This topic is 3270 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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...

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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" ?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This topic is 3270 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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