Title
Mac Question - Use Filemaker's Applescript functionality to open a Finder window to a directory
Post
Hi, I am trying to use Filemaker to run an Applescript (using the Perform Applescript command) that will open a Finder window to a directory that I want to get access to. The trick here is, is that this directory is going to be composed of multiple elements of a field on one of my Filemaker table layouts. Here's an example of what I want to do:
I have a table of records in Filemaker, each with a unique document number field that I assign to each record. The Document number is in the form of a phone number (XXX-YYY-ZZZZ). Each record in my database has associated files on my Mac that are organized according to their document number in a file on the root drive called "FILES" (so its path is "/FILES"). So if I am looking at a record with Document Number 123-456-7890, I want the Finder to open a new window and navigate to the folder "/FILES/123/456/" (where files 123-456-0000 through 123-456-9999 are stored) - and if possible - highlight that record in that directory. So how can I do this?
And if that method can't be done, can I use Filemaker to tell Applescript to just plug that whole field into a Spotlight search?
Thanks.
Daniel Clark:
Thanks for posting!
You can accomplish this by using the calculated AppleScript option within the Perform AppleScript step. I've included the basic calculation below. You'll just need to edit the table and field names.
"tell application \"Finder\"" & ¶ &
"activate" & ¶ &
"reveal POSIX file \"/FILES/" & Left(${tableName}::fieldName;3) & "/" & Middle(${tableName}::fieldName;5;3) & "/" & Right(${tableName}::fieldName;4) & "\"" & ¶ &
"end tell"
This will equate to the following:
tell application "Finder"
activate
reveal POSIX file "/FILES/<the first three characters in your field>/<the 5th-7th characters in your field>/<the last 4 characters in your field>"
end tell
Please let me know if you run into any issues implementing this.
TSBear
FileMaker, Inc.