July 20, 201114 yr Relatively new to FileMaker Pro and using version 10. I have googled the topic and spent many hours researching solutions and tried 3 different approaches, all with erroneous results. The database manages employee records. I want to create a script that automatically creates a folder, named by the fields CREW::FirstName & " " & CREW::LastName and located in Documents/Personnel/Crew/Current, after completing the last name field of a new record (i.e. activated via script trigger on this field) and I do not want it to replace a folder of the same name. Latest attempt: Calculated Applescript step - "do shell script \"mkdir /Macintosh HD:Users/Dan/Documents/Personnel/Crew/Current/" & CREW::PersonalDetailsFolderName & " 2> /dev/null\"" Previous attempt: Native Applescript step - --tell application "FileMaker Pro Advanced" set FolderName to cell "PersonalDetailsFolderName" of current record --end tell set FolderPath to path to "Macintosh HD:Users/Dan/Documents/Personnel/Crew/Current" tell application "Finder" try make new folder at FolderPath with properties {name:FolderName} end try end tell First attempt: Script steps - Set Variable [$NewFolder ; CREW::FirstName & " " & CREW::LastName & "/"] Perform Applescript [Let ( Qmk = "'" ; " do shell script " & Qmk & "mkdir /MacintoshHD/Users/captainmyladymarina/Documents/Personnel/Crew/Current/" & CREW::PersonalDetailsFolderName & Qmk )] - Calculated Applescript All result in errors. I'm sure all approaches are syntax errors. I wish I could find a good reference for script syntax; however, I would gladly accept an explicitly written code suggestion. Please help.
July 20, 201114 yr I think you are mixing two forms of path syntax: within AppleScript, the folder path should be specified as: "Macintosh HD:Users:Dan:Documents:Personnel:Crew:Current" Within a shell script, it should be: "/Users/Dan/Documents/Personnel/Crew/Current"
July 21, 201114 yr Author Hello "Consultant", Thank you for your reply. Based on your syntax error observation, the only attempt this applies to is the Previous where I used Native Applescript. Therefore, I changed this script accordingly to: --tell application "FileMaker Pro Advanced" set FolderName to cell "PersonalDetailsFolderName" of current record --end tell set FolderPath to path to "Macintosh HD:Users:captainmyladymarina:Documents:Personnel:Crew:Current" tell application "Finder" try make new folder at FolderPath with properties {name:FolderName} end try end tell Result returned same error message - "Object not found". Then after clicking "OK" - "Unknown Error: -1728." Please help.
July 21, 201114 yr Author Hello again "Consultant", My bad; I noticed I must also change the latest shell script attempt as follows: "do shell script \"mkdir /Macintosh HD/Users/Dan/Documents/Personnel/Crew/Current/" & CREW::PersonalDetailsFolderName & " 2> /dev/null\"" The error message is still the same with this as well - "The command exited with a non-zero status." Please help.
July 21, 201114 yr Your path is still incorrect. Also, if you want the directory to be created automatically, you need to use mkdir -p, I think. I am not sure what the > /dev/null part is for. BTW, you can generate the first part of the path dynamically with: set myPath to POSIX path of (path to documents folder) & "Personnel/Crew/Current/"
July 21, 201114 yr Author Hello again "Consultant", Can you please tell me specifically what is wrong with the path as written in my last post; I don't see the incorrectness to which you refer? As I understand it, mkdir -p will overwrite any existing folder, which I do not want to do; I only want to create the folder if it does not already exist. FYI, this approach was learned from the following forum: http://hintsforums.macworld.com/archive/index.php/t-85125.html Also, I assume your last dynamic path suggestion applies as follows? --tell application "FileMaker Pro Advanced" set FolderName to cell "PersonalDetailsFolderName" of current record --end tell set FolderPath to POSIX path of (path to documents folder) & "Personnel/Crew/Current/" tell application "Finder" try make new folder at FolderPath with properties {name:FolderName} end try end tell FYI, this approach was learned from the following forum link: http://fmforums.com/forum/topic/58887-creating-a-folder-alias-with-applescript/ Thanks again!
July 21, 201114 yr Can you please tell me specifically what is wrong with the path as written in my last post You have: /Macintosh HD/Users/Dan/Documents/Personnel/Crew/Current/ You should have: /Users/Dan/Documents/Personnel/Crew/Current/ As I understand it, mkdir -p will overwrite any existing folder, which I do not want to do -p Create intermediate directories as required. If this option is not specified, the full path prefix of each operand must already exist. On the other hand, with this option specified, no error will be reported if a directory given as an operand already exists. http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/mkdir.1.html See also: http://macscripter.net/viewtopic.php?id=16156 I assume your last dynamic path suggestion applies as follows? No, I was still referring to the shell script. You cannot use a POSIX path with Finder.
July 22, 201114 yr Author Hello again "Consultant", OK, all is clear with mkdir -p and your recommendations regarding POSIX; however, I still seem to have an issue that I need to use a field name as the dynamic part of the folder, so I assume this must be a calculated Applescript. I assume all lines of this suggested Applescript approach should be 1 line of a FileMaker script; i.e. Perform Applescript? The calculated Applescript does not handle double quotes, which it appears that I need (it closes the quote rather than quote within a quote). Separate Applescript lines of command in the FileMaker script don't work; the next line does not recognize a variable established in a previous Applescript line. Here again, I'm lost in the syntax. Sorry for all the hand-holding, but I'm new to this; all suggestion thus far make sense by themselves but I am lost in the assembly. If you could suggest exactly each FileMaker Applescript step of your recommendation, I might be able to glean the approach pattern for this and future uses. Thank you.
July 22, 201114 yr I need to use a field name as the dynamic part of the folder, so I assume this must be a calculated Applescript. No, it doesn't - you can use native AppleScript to get data from Filemaker, like you did in your first attempt: --tell application "FileMaker Pro Advanced" set FolderName to cell "PersonalDetailsFolderName" of current record --end tell I assume all lines of this suggested Applescript approach should be 1 line of a FileMaker script; i.e. Perform Applescript? Yes. The calculated Applescript does not handle double quotes, which it appears that I need A calculated AppleScript must return the text of a valid AppleScript. AppleScript itself does not accept nested quotes of the same type - but it does accept single-quoted expression within a double-quoted one, e.g. If you could suggest exactly each FileMaker Applescript step of your recommendation, I might be able to glean the approach pattern for this and future uses. Hopefully you should be able to put it together now. I could write it out for you, but where is the fun in that? do shell script "mkdir -p '/Users/Dan/Documents/Personnel/Crew/Current/'" But you don't need to worry about quotes if you pre-define some variables as text. For example: set myPath to POSIX path of (path to documents folder) & "Personnel/Crew/Current/" set myCommand to "mkdir -p " & quoted form of myPath At this point, the variable myCommand contains the string: "mkdir -p '/Users/Dan/Documents/Personnel/Crew/Current/'" and all you need to do is add: do shell script myCommand
July 22, 201114 yr Author OK, I should've seen Applescript retrieval of the FM Pro cell myself. However, my Applescript is still returning error messages: "Object not found" and then when OK is clicked, "Unknown error :-1728." Exact script is: --tell application "FileMaker Pro Advanced" set FolderName to cell "PersonalDetailsFolderName" of current record --end tell set FolderPath to POSIX path of (path to documents folder) & "Personnel/Crew/Current/" set mkdirStr to "mkdir -p " & quoted form of FolderPath & quoted form of FolderName do shell script mkdirStr What am I missing...?
July 22, 201114 yr Try this in AppleScript Editor (while your Fiiemaker solution is open): tell application "FileMaker Pro Advanced" set FolderName to cell "PersonalDetailsFolderName" of current record end tell set FolderPath to POSIX path of (path to documents folder) & "Personnel/Crew/Current/" set mkdirStr to "mkdir -p " & quoted form of FolderPath & quoted form of FolderName What do you see in the Result tab?
July 22, 201114 yr Author error "FileMaker Pro Advanced got an error: Object not found." number -1728 from cell "PersonalDetailsFolderName" of current record
July 22, 201114 yr Author OK, found http://help.filemaker.com/app/answers/detail/a_id/4285/kw/protect%20fields%20from%20modification/session/L3RpbWUvMTMxMTM2MTg2Ni9zaWQvQzdCamNFems%3D and realized error resulted from field not on the layout. Put the field on the layout and ran again in Applescript Editor (because it is not performing in FM, but no longer giving error messages: "mkdir -p '/Users/captainmyladymarina/Documents/Personnel/Crew/Current/'''\\''Daniel Higlett'\\'''" Seems the forward slashes and quote arrangement is wrong. Any ideas? Regarding my last, seems like I'm striving for: "mkdir -p '/Users/captainmyladymarina/Documents/Personnel/Crew/Current/Daniel Higlett'" But not sure how to get there.
July 22, 201114 yr I was hoping seeing the result would make it clear: you are appending two quoted strings,when they need to be inside the same quote. Try it this way (untested): --tell application "FileMaker Pro Advanced" set FolderName to cell "PersonalDetailsFolderName" of current record --end tell set myPath to POSIX path of (path to documents folder) & "Personnel/Crew/Current/" & FolderName & "/" set myCommand to "mkdir -p " & quoted form of myPath do shell script myCommand
July 23, 201114 yr Author Well, that did the trick! Thank you again!! BTW, I didn't see it because I don't yet see the difference between appending the 2 quoted strings "mkdir -p " & quoted form of myPath and quoted form of FolderPath & quoted form of FolderName. Too new to this I guess but learning...
July 23, 201114 yr I don't yet see the difference Appending two quoted strings: quoted form of "a" & quoted form of "b" returns: "a""b" Appending two strings, then quoting the result: set c to "a" & "b" quoted form of c returns: "ab"
March 10, 201411 yr Newbies hope i can tack on to the end of this thread im trying to do almost the same thing as above but to a NAS drive... any help?
March 14, 201411 yr hope i can tack on to the end of this thread im trying to do almost the same thing as above but to a NAS drive... any help? You'd have to quote what NAS drive you’re using and what version of unix it is running. The above commands apply to Mac OSX, as far as I can tell.
Create an account or sign in to comment