Headlines, Hints & Tips

Hints & Tips

Auto-Detect Mounted Volumes

Helping set up for the [AUPN](http://www.apertureprofessional.com/) launch party this weekend, I needed to load files onto 100 USB flash drives for the obligatory [swag](http://en.wikipedia.org/wiki/Swag) bag. To churn through it efficiently, we had an Automator workflow copy the files onto the drives. All I had to do was insert a drive, double-click the workflow app, wait until it copied the files and unmounted the drive, then unplug the drive.

After doing this a few times, it seemed silly having to manually run the workflow; I wanted it to run automatically when a drive was plugged in. Fortunately, the solution came to me in a flash (pun absolutely intended).

It occurred to me that a [folder action](http://www.apple.com/applescript/folderactions/) should detect not only files, but also devices. When you mount a drive, what folder does it appear in? Your instinct may say "the Desktop," but this is a Finder illusion. In fact, mounted drives appear in the invisible root-level directory /Volumes/.

Thus, I saved the workflow as a folder action plug-in for /Volumes/, and it worked perfectly. All I had to do was insert a flash drive, wait for the workflow to finish, remove the drive, and insert another one – 100 times.

Here are the steps:

1. Go to *File > Save As Plug-in*.
2. Choose *Folder Action* from the pop-up menu.
3. In the *Attach to Folder* pop-up, select *Other...*
4. In the resultant open dialog, hit *cmnd-shift-g*. This will bring up a small sheet labeled *Go to the folder:*.
5. In this sheet, type `/Volumes/`, and hit the *Go* button, then hit *Open*.
6. Hit the *Save* button in the Plug-in sheet.

With this trick, any mounted device will trigger the attached workflow. What that workflow does is up to you, but the possibilities are endless.

Comments

14 Comments »

  1. I need to do something similar but in reverse. I’ve got 400 CDs & DVDs I need to copy to a FireWire drive.

    Thing is I can’t figure out how to select all the files in the newly mounted volume. Any ideas?

    Thanks,

    T.

    Comment by T. Payton — March 16, 2007 @ 5:35 pm

  2. T- See my forum posting.

    Comment by Steve — March 16, 2007 @ 6:24 pm

  3. I am looking for a workflow that allow me to download the photos to a specific folder , then create a ivew catalog with that folder to select and rename files, and then open the selected images in Adobe Lightroom to be developed.
    Do you know where can I find this kind of workflow? I was trying imphoto but only download the files to the pictures file, when I need to direct which file.
    I will apreciate any information.
    Thank you.

    Comment by Xavier Jacome — May 10, 2007 @ 6:35 pm

  4. Thanks for this tip. For a while now I have wanted a copy operation to execute when I insert a flash drive. The drive will contain files I need to take to work, This is a good way to make sure I always have the most recent version.

    Comment by Sylvester — May 12, 2007 @ 3:38 pm

  5. T. Payton, I have similar problem too! Do you have any ideas for now?

    Comment by iMax — July 6, 2007 @ 8:14 am

  6. I’m looking for a way to simply mount external hard drives on another computer on a network. Is there an automator script that will activate the “GO” Finder command?

    Comment by Mac Carter — July 29, 2007 @ 9:22 am

  7. Thanks alot! by the wayyou cant put the plug-in in the ipod it has to be in ‘/Volumes/’

    cheers!
    bo

    Comment by robert huttinger — October 11, 2007 @ 9:30 am

  8. I was just wondering, as you mentioned in the last line any connected device would trigger this workflow, is it possible to narrow it down to a particular drive based on the drive name/label because i want to use this workflow to copy files to a USB hard drive and it shouldn’t happen when i plugin a USB memory stick!

    Comment by bala — February 1, 2008 @ 2:45 pm

  9. Hi All. I’m bumping this months later because for whatever reason, iPhoto no longer sees my CF cards when I mount them and automatically starts importing my pictures, but the Finder still sees it just fine. So I’m trying to create a simple action to essentially re-create this previous behavior. (FWIW, it stopped working upon a hard drive failure and subsequent fresh install of Leopard on a new hard drive.) This tip is very helpful and gets me much of the way there, but I’m hoping there’s some way to essentially only run the workflow/action when my CF cards are mounted, not when any device is mounted. I am, by the way, completely new to Automator, so any mind-expanding ideas, however obvious to the initiated, are welcome! Thanks for the help!

    Comment by Joel — April 28, 2008 @ 12:42 am

  10. Thanks for the tips.

    I’ve got an automated process going now whenever I insert some of my cards, but now, how can I remove a workflow from the /volumes folder?

    Thanks.

    Comment by Ben — September 18, 2008 @ 6:57 am

  11. Hi all,

    I had similar questions to the ones you guys were asking about running a workflow when a specific device is mounted, after some searching I found this…

    http://automator.us/examples-08.html

    hope that helps.

    Comment by Phil — January 2, 2009 @ 9:01 pm

  12. am love your automatorworld & it’s very usefull.

    now i want to make one automator …
    i use many pendrive for data transfer & use.
    i want instatant copy automatore which he copy all my pendrive data in my document in one folder..
    i need urgent please give hints or move clipe to how to do this type of automatore.

    i hope you replay soon..
    thank you
    from
    vasudev

    Comment by vasudev — August 9, 2009 @ 6:14 am

  13. Hello. We are working on an application that we want to copy a finished file to a USB storage device like your app, but I would like to mount the USB device first before an event and then when the event is finished automatically copy the file without having to remember to stick the drive in everytime. Is this possible? The whole Automator script would be ical triggered.

    Thanks,

    Casey

    Comment by Casey Booey III — November 22, 2009 @ 4:54 pm

  14. this works on my 10.4 machine
    but won’t install on 10.6.3

    HELP!

    Comment by pete — April 1, 2010 @ 6:34 am


Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>