oleynikd
oleynikd

Reputation: 932

How to open finder on Mac OS X automatically when USB plugged in?

Super simple question, but I can't fond the answer.

I want the Finder to open mounted disk when I plug in USB drive... How?

Upvotes: 2

Views: 3329

Answers (3)

Walkman
Walkman

Reputation: 119

Adding to @MarkSetchell's answer, to make the /Volumes folder visible I had to use sudo chflags nohidden /Volumes instead. However an easier way to make this folder visible (and Temporarily, which might be preferred) is with a key combination:

Cmd (⌘) + Shift + .

(also my context menu item is Services > Folder Actions Setup)

And to save others the pain, the folder these scripts are saved in is /Library/Scripts/Folder Action Scripts (I'm ashamed to say it took me a few hours to find it)

Create a new file there using the terminal and sudo, paste the script above, and add it in folder actions setup. It works like a charm (for me at least).

Upvotes: 1

oleynikd
oleynikd

Reputation: 932

Thank you @mark-setchell

I've ended up with this Apple Script for my /Volumes folder:

on adding folder items to this_folder after receiving added_items
    try
        tell application "Finder"
            --open window and activate finder 
            activate
            --open the USB
            open added_items
        end tell
    end try
end adding folder items to

So every time some new item appears in /Volumes folder Finder opens window and selects this item.

This solution has some delay before opening finder (5-10 sec). I guess Folder Actions just work this way...

Upvotes: 3

Mark Setchell
Mark Setchell

Reputation: 207853

You should be able to do this by adding a Folder Action to the folder Volumes which is where external disks get mounted. AFAIK, you can only do that in the Finder and the /Volumes folder is set invisible in the Finder - thanks, Apple.

So, first make the /Volumes folder visible to the Finder, by starting the Terminal and running

sudo SetFile -a v /Volumes

Now, start the Finder and select your System drive and then Macintosh HD on the left pane. You should now see

  • Applications
  • Library
  • System
  • User
  • Volumes

Right-click on the Volumes folder and go to Setup Folder Actions and attach the add - new item script. You can then diddle around with that to do whatever you want the Finder to do when a disk is inserted.

Upvotes: 1

Related Questions