Jump to content
Server Maintenance This Week. ×

How to Script an "Open Folder" On Mac


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

Recommended Posts

I'm trying to script a command to open a folder on the Mac

My PC solution just uses a send event which works just fine, but does nothing on the mac.

I'm setting a variable that is the $Filepath and passing that to the send event open document script command but nothing happens.

Any ideas - maybe an apple script (something I'm not competent in at all)

Thanks

Link to comment
Share on other sites

Well, the AppleScript can be as simple as:


tell application "Finder"

activate

open "Macintosh HD:Users:fej:Desktop:Registrations xml:"

end tell



The "activate" above brings the folder to the front; otherwise it opens behind FileMaker's window.



You would need to put this in a Perform AppleScript step, by calculation, with the path produced from a field (I suppose, I don't know whether your folder path is static or dynamic). You have to escape the quote marks, by preceding with a backslash; i.e., the result must look like the above. Notice a folder path ends in ":".



You can see that the AppleScript file path syntax is not the same as FileMaker's (nor Unix, nor Windows). But it's pretty easy to convert a FileMaker syntax path to AppleScript's syntax. Just take off the "filemac:/" and Substitute "/" with ":". 



The drive name, "Macintosh HD", may differ on different machines, as it is user-editable. You can use one of FileMaker's functions to get it, like Get ( DriveName ), Get ( DocumentsPath ) or Get ( DesktopPath ).



Alternatively, you can use OpenURL, with a path like this (yes, 3 "///"):





"file:///Users/fej/Desktop/Registrations xml/"

Edited by Guest
Link to comment
Share on other sites

I just knew the venerable Fenton (maybe it should be "fountain" considering the widsom you pour out on this forum) would arrive with the solution.

Ah yes, the /// is what did me in on the open url approach

I tried opening the finder as a script command but not in the apple script. That went nowhere also.

As always, thanks a million Fenton.

Link to comment
Share on other sites

  • 1 month later...

Is there a simple way to simply open the file path in a finder window. I don't want the actual file to open, just take the user to the location in a new finder window. Something like this:

set test to alias "Macintosh HD:Users:brett:Documents:Mileage:2007.10.3 TDS Mileage.xls"

tell application "Finder"

activate

open (path to test)

end tell

Link to comment
Share on other sites

The cutest way is to use the "reveal" command. If you have the file path, it will open the folder, then highlight the file.

set test to alias "Macintosh HD:Users:brett:Documents: Mileage:2007.10.3 TDS Mileage.xls"

tell application "Finder"

activate

reveal test

end tell

Link to comment
Share on other sites

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