ddinisco Posted April 5, 2008 Posted April 5, 2008 I am trying to run an applescript (below) from within a filemaker script where the first set of quotes (which is the patch "David:Documents:test:xfer") is the value of a filemaker field. I have done this before with: set x to cell "myField" of current record... and a do shell script command, but that does not seem to work here. Any help here would much appreciated. Also should I be using Native AppleScript of Calculated AppleScript? set folder_to_alias to "David:Documents:test:xfer" as alias tell application "Finder" to make new alias file at desktop to folder_to_alias
Fenton Posted April 5, 2008 Posted April 5, 2008 Where's the 1st part of the file path, "Macintosh HD:Users:"? Or whatever your drive name is. Or use a variable to build the path, which will dynamically include the short user name: set doc_path to path to documents folder as Unicode text set folder_to_alias to doc_path & "Scripts" as alias tell application "Finder" to make new alias file at desktop to folder_to_alias
ddinisco Posted April 5, 2008 Author Posted April 5, 2008 Hi Fenton Not quite understanding this. 1. If I set a variable for the path (variablePath), how do I add that variable into the applescript? 2. What is "Scripts" supposed to indicate? I am running this as a script, using the perform applescript command set to NativeAppleScript. Thanks David
ddinisco Posted April 5, 2008 Author Posted April 5, 2008 This works, but how do I change the path of "myServer:myFolder:mySubfolder" to a variable or a field in filemaker. set doc_path to path to "myServer:myFolder:mySubfolder" set folder_to_alias to doc_path as alias tell application "Finder" to make new alias file at desktop to folder_to_alias
Fenton Posted April 5, 2008 Posted April 5, 2008 It's confusing talking about FileMaker, AppleScript and the OS in one short post. I guess I shouldn't have used the word "variable" without clarification. Since we were talking about AppleScript, I meant an "AppleScript variable" (like "doc_path" in your AppleScript). Normally I used the phrase "script Variable" when talking about a FileMaker script Variable. "Scripts" is just the name of a folder in my Documents folder. You likely have it also.
Fenton Posted April 5, 2008 Posted April 5, 2008 It is a good question, whether to run this via a calculation, or using native AppleScript (entered directly in the Perform AppleScript dialog). I usually use the later, but in cases where the script is short, a calculation can be better. Because, if you just enter the AppleScript you have to know something about the object hierarchy of FileMaker's AppleScript, in order to get access to a field's value. Or you have to first go to a layout and record with the field on it; then AppleScript can always get it easily. The advantage of running via the (•) Calculated AppleScript option is that FileMaker will get the value for you, and pass it to the AppleScript. And you already know the rules for FileMaker access to the field. The disadvantage is the you have escape quotes and insert line breaks where needed. I suggest building the entire AppleScript in a single unstored calculation field. Then look at the result on a layout. You will see any problems. You still need FileMaker access to that calculation field, but it does not need to be on the current layout, nor do you need to hard-code its layout or table occurrence name (which you might otherwise). "set folder_to_alias to alias " & Quote ( Server_Path ) & ¶ & "tell application "Finder" to make new alias file at desktop to folder_to_alias" [P.S. the above takes the server path from a field. But you could just type it directly into the calculation, escaping the quotes, like I did with "Finder"]
Newbies zenmoused Posted September 17, 2009 Newbies Posted September 17, 2009 I'm stuck at the same roadblock. I'm creating a database that a group of people can use to look up their "speaker numbers" for an event, and press a button to create a folder on the desktop that's already named with their last name and speaker number. Overwriting isn't an issue, we just want ease of use. Here's what I have so far: tell application "Finder" make new folder at alias "(path)" with properties {name:"DATABASE::LASTNAME"} end tell When I plug in other values for the name, it works just fine. I can't however get it to plug in values from the current record. Can anyone help me? Thanks, Brian
Fenton Posted September 17, 2009 Posted September 17, 2009 (edited) This is how I might create a folder on the Desktop, based on a FileMaker field, if it was in a Perform AppleScript step: --tell application "FileMaker Pro Advanced" set folder_name to cell "NameLast" of current record --end tell set DT to path to desktop tell application "Finder" try make new folder at DT with properties {name:folder_name} end try end tell You'll notice that the "tell FileMaker" commands are commented out, when using inside FileMaker. If used (or edited) in AppleScript Editor, you'd uncomment those 2 lines. Notice also that the call to FileMaker is NOT inside the Finder tell block. In the above case the field "NameLast" must be on the current layout also. Otherwise you could get it, but you'd have to specify the layout or table (table occurrence) name. On the layout is easiest (and in this case likely). Notice also there are no quotes around "folder_name". It's an AppleScript variable, so it does not need them. The "path to Desktop" is not in the Finder tell block either. It does not like it. However, if all you're doing is creating a folder on the desktop, with no further addition to that, then the Finder (and I think only the Finder) can target it directly, like this: --tell application "FileMaker Pro Advanced" set folder_name to cell "NameLast" of current record --end tell tell application "Finder" try make new folder at desktop with properties {name:folder_name} end try end tell P.S. The "try" is because it is an error to overwrite an existing folder; AppleScript will not overwrite a folder. With "try" it will just not display the error (nor overwrite). Edited September 18, 2009 by Guest
bruceR Posted September 18, 2009 Posted September 18, 2009 (edited) I prefer to do this a little differently, for troubleshooting purposes Set variable [ $mydata; substitute( relation::fieldname; " "; " ")] # escape spaces Set variable [ $myscript: "do shell script 'mkdir -p ~/desktop/myFolder' " Set variable [ $myscript ; substitute( $myscript; "myfolder"; $mydata] Perform applescript [ $myscript ] Not if $mydata contains "aa/bb/cc/theFolder" all intermediate folders will be created automatically and with -p any existing folders will get overwritten. Edited September 18, 2009 by Guest
EllenG Posted January 14, 2010 Posted January 14, 2010 I used your applescript code to create a folder and it worked great!! This is the one I used, since my folder will always go to the desktop. tell application "Finder" try make new folder at desktop with properties {name:folder_name} end try end tell Wonder if you have a simple solution like this that will delete a folder from the desktop, or delete the files in the folder?? The folder will always be the same name. Thanks.
Recommended Posts
This topic is 5796 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 accountSign in
Already have an account? Sign in here.
Sign In Now