Forums > MaxMSP

Locate in Finder

Apr 25 2014 | 2:14 pm

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… ;)


Apr 25 2014 | 3:47 pm

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:

-- Pasted Max Patch, click to expand. --

Apr 25 2014 | 4:33 pm

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

Apr 25 2014 | 5:41 pm

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?

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

-- Pasted Max Patch, click to expand. --

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?

Apr 25 2014 | 6:06 pm

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.

Apr 25 2014 | 6:20 pm

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

Apr 26 2014 | 4:29 am

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

-- Pasted Max Patch, click to expand. --

Apr 26 2014 | 6:08 am

Cool, thanks ;)

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

Apr 26 2014 | 1:47 pm

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.

-- Pasted Max Patch, click to expand. --

Apr 26 2014 | 3:29 pm

Thanks a lot, very helpful!

Viewing 10 posts - 1 through 10 (of 10 total)

Forums > MaxMSP