April 3, 200619 yr I just read a post about this dating back to 2002. It stated that I should have an applescript that looks like the following tell application "Finder" activate reveal filepath end tell I have a field that has the filepath, e.g. Powerbook/Users/jeffbills/Filemaker Info & Packages/FILEMAKER DOCS/ FMUG SACFM Directions.pdf How do I insert this filepath into the 'reveal filepath' step in applescript? I've tried using a variable but everytime I use the "$" symbol I get an error message Thanks
April 4, 200619 yr I just read a post about this dating back to 2002. It stated that I should have an applescript that looks like the following tell application "Finder" activate reveal filepath end tell I have a field that has the filepath, e.g. Powerbook/Users/jeffbills/Filemaker Info & Packages/FILEMAKER DOCS/ FMUG SACFM Directions.pdf How do I insert this filepath into the 'reveal filepath' step in applescript? I've tried using a variable but everytime I use the "$" symbol I get an error message Thanks You have to make sure that 1. the applescript is properly quoted and escaped, and 2. that the filemaker string is also properly quoted and escaped. Not easy, but doable. The key is to think first about how you want the string to look in AppleScript: reveal "Powerbook/Users/jeffbills/Filemaker Info & Packages/FILEMAKER DOCS/ FMUG SACFM Directions.pdf" You want the file path to be inside one matching pair of quotation marks. Next, you need to think of how to get this string to work in FIleMaker. Remember that filemaker is also going to be watching for quotation marks. So, within FileMaker, this string snippet should look something like this: "reveal "Powerbook/Users/jeffbills/Filemaker Info & Packages/FILEMAKER DOCS/ FMUG SACFM Directions.pdf"" The backslash "esacpes" the following quote character so it is interpreted as a literal quote. If using variables, it will be something like this: "reveal "" & $filePath & """ As part of a mult-line applescript, you will also need to add end-of-line symbols (the paragraph symbol) after each line.
April 4, 200619 yr FYI, if you are using Unix-format paths, you also have to deal with Posix Paths in applescript. Here's how I do it: // Applescript: reveals the file in the finder "tell application "Finder"¶" & " set posixPath to "" & $path & """ & ¶ & " set theAlias to POSIX file posixPath as alias" & ¶ & " reveal theAlias¶" & "end tell"
April 4, 200619 yr Also, unless "Powerbook" is another mounted drive, which I doubt, the Unix path would not have it in the name. It just uses "/" for the root, leaving out the name of the startup drive (which is a good idea). So the POSIX path would just be: /Users/jeffbills/Filemaker Info & Packages/FILEMAKER DOCS/ FMUG SACFM Directions.pdf
April 4, 200619 yr And while we're on the topic -] If you ever need to get the path to your home folder, rather than hard-coding it, AppleScript can easily get this. For Mac path: path to home folder -- returns an alias (path to home folder) as string -- string (duh) For Unix path: do shell script "echo $HOME"
April 4, 200619 yr Also, unless "Powerbook" is another mounted drive, which I doubt, the Unix path would not have it in the name. It just uses "/" for the root, leaving out the name of the startup drive (which is a good idea). So the POSIX path would just be: /Users/jeffbills/Filemaker Info & Packages/FILEMAKER DOCS/ FMUG SACFM Directions.pdf Or, prefix it with "/Volumes/", e.g. "/Volumes/Powerbook/..." /Users/jeff is the same as /Volumes/HardDiskName/Users/jeff for your boot disk.
April 5, 200619 yr Author Hey all Here's what I what i've done (see attachment) I'm not getting it to work Note that there is a space between the first quote and "Powerbook" . . . thus, " Powerbook" That's just how I've named my hard drive so i can access it quickly from the desktop by pressing the space bar Thanks!
April 5, 200619 yr I'm not very good with applescript, but I think the problem is that you can't use a posixpath (aka unix-style path, the ones with forward slashes) like that. See my example above which does it in two steps -- the first step converts the posix path to an alias to the file, and the second opens the alias.
April 5, 200619 yr PJB, you haven't told us where you're getting this file path from. Maybe you could just give it to AppleScript in the Mac form in the first place: tell app "Finder" reveal alias " Powerbook:Users:jeffbills:Filemaker Info & Packages:FILEMAKER DOCS: FMUG SACFM Directions.pdf" end tell
April 5, 200619 yr Author Fenton, What you wrote is the start of what I needed. I have a field called "filepath" that produced the following from a script I used getting a file path from an image in a container field, similar to a script used in a document you posted for importing (jpg's or pdf's?) using applescript into FM. The result was: Powerbook/Users/jeffbills/Filemaker Info & Packages/FILEMAKER DOCS/ FMUG SACFM Directions.pdf It has "/'s" instead of ":'s." Then, I changed it so it looked like your last post Powerbook:Users:jeffbills:Filemaker Info & Packages:FILEMAKER DOCS: FMUG SACFM Directions.pdf NOW . . . my "perform Applescript" step merely looked like the following as I'm trying to learn Applescript" tell application "Finder" activate reveal alias " Powerbook:Users:jeffbills:Filemaker Info & Packages:FILEMAKER DOCS: FMUG SACFM Directions.pdf" end tell AND IT WORKS as written above BUT what I'm trying to do is set the "reveal alias" portion of the applescript to the contents of the field (filepath) or use a variable something like the following tell application "Finder" activate reveal alias $filepath end tell THANKS ALL for all of your input. What's my next step?
April 5, 200619 yr That's where I thought it was coming from, a FileMaker syntax file path, which has "/", and also a prefix "filemac:". What xochi was showing was how you can use the POSIX file AppleScript command to turn the FileMaker path (without the prefix) into a "regular" Mac path (with ":"). All these things are more or less the same thing, just different syntax. In other to get it to work as you posted above, you have to put a full Mac path to the file into your script Variable. I would use the Substitute() function to produce a Mac path from the 3rd line of the info for the image. FM_path_to_cAS.zip
Create an account or sign in to comment