Jump to content
Server Maintenance This Week. ×

Revealing document in finder from fm filepath


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

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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

Link to comment
Share on other sites

And while we're on the topic :D-] 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"

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

FileMaker_Pro_Advanced002.jpg

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 6609 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.