Locate in Finder

danieleghisi's icon

Hello everybody,

Some Mac applications have a "Locate in Finder" button which opens a Finder window and selects a given file.
Does anybody know if there is there a way to achieve something like this in Max?

If it was cross-platform that'd be even better (of course by replacing the Mac Finder with the Windows equivalent... ;)

Thanks,
Daniele

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

It's probably not working on windows, but you can do something close with a few objects on mac. The patch show the folder which contains the file you want to see in the finder:

Floating Point's icon

and place a [tosymbol] between regexp and ;max message to allow for spaces in filepath name

danieleghisi's icon

Thanks to both of you for the useful tips.
This solves the folder opening, but not the file selection (at least on my machine)...
Is there maybe a way to achieve also this last bit?

Max Patch
Copy patch and select New From Clipboard in Max.

For instance: is there a way to run applescripts within Max?
I was hoping to run an applescript with [shell] – say like this:

where the applescript is something simple, like

on run argv
    set thePath to POSIX file (item 1 of argv)
    tell application "Finder" to reveal thePath
end run

This script works perfectly from the Terminal command line, but it doesn't work with [shell].
Does anybody know why?

danieleghisi's icon

Yeah, just a matter of escaping double quotes, and everything works!
For instance:

osascript \"/Path/To/My/File/revealfile.scpt\" \"/Applications/Max 6.1/examples/sounds/drumLoop.aif\"

Thanks guys!

It seems that applescript via [shell] is the way to go, at least for my case.

danieleghisi's icon

Actually, as a final remark, one should also addtell application "Finder" to activate
at the end of the apple script, to bring the Finder to the front.

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You can call reveal directly without a script (and enjoy string escaping hell ;-):

danieleghisi's icon

Cool, thanks ;)

(Does anybody have any idea of how to possibly export this into Windows? Is there something similar to "applescript"?)

11OLSEN's icon
Max Patch
Copy patch and select New From Clipboard in Max.

yes indeed. there's vbscripts or batch files even executeable without shell object with max launchbrowser message.
i'm currently playing around on both sides mac/win. i once made this to open explorer and select the file. it's from an old device and i didn't test it again, but you can see how to execute a shell command on windows without 3rd party external. vbscript can do similar things like applescript, but of course, uses more cryptic syntax.

danieleghisi's icon

Thanks a lot, very helpful!