Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm familiar with

explorer /select,/path/to/something

To open the folder that contains a file, with that file highlighted, in windows explorer. Anybody know of a one liner (or one liner applescript) to do the same for OS X with the Finder? Google search didn't seem to reveal much in the way of one liners.

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

The open command normally acts as if you double-clicked a file, but it has a -R flag to reveal the argument in finder. Therefore, you're looking for:

open -R /path/to/something

For further information, consult the open man page.

share|improve this answer
add comment

Finder's AppleScript dictionary has a reveal command:

tell app "Finder" to reveal POSIX file "/private/etc"

But it doesn't bring Finder to the front or use your default view options for the created window.

This should additionally do both of those:

tell application "Finder"
    reopen
    activate
    set selection to {}
    set target of window 1 to (POSIX file "/private/etc")
end tell
share|improve this answer
add comment

I have modified the code found in this article, it's not tested, but it's still something.

property the_path : "/Library/Scripts/file.ext"

--No more edits.

set the_folder to (POSIX file the_path) as alias
tell application "Finder"
if window 1 exists then
set target of window 1 to the_folder
else
reveal the_folder
end if
end tell
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.