Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'd like to run a script (removing non-OSX .* files) on a USB drive whenever that drive is ejected - is there a way to trigger a script automatically when a drive is ejected from the Finder?

To clarify: I'm looking for a way of triggering a given script before the umount command runs, i.e. immediately before the drive is ejected. I'm aiming to delete .* files and run dot_clean before a FAT drive ejects, getting rid of OSX-only invisible files that confuse Windows systems.

share|improve this question
1  
How would you run a script on a USB drive after you have ejected it? –  duci9y Sep 17 '12 at 15:26
    
It would run BEFORE the drive ejects ... when the Finder starts the process of unmounting it. Presumably there is a way of running a script before umount runs. –  Simbamangu Sep 17 '12 at 18:15
    
I don't believe there is anything that allows you to do that. Also, you would perhaps like to edit your question to include that the script should be run run before the drive ejects. –  duci9y Sep 17 '12 at 18:23
    
There is a hack to let you do something like this - renaming umount and creating a new umount script that removes dotfiles and then calling the old umount. Will give this a try anyway. –  Simbamangu Sep 20 '12 at 12:34
    
That’s great! Add that as an answer and accept it so that future visitors with the same problem know that there is a solution. –  duci9y Sep 20 '12 at 12:56

1 Answer 1

There is some 3rd party software (UnDock) which allows you to run scripts when drives are ejected.

share|improve this answer
    
It doesn't seem to support that. You can only tell it to run scripts when disks are ejected manually with it. –  ؘؘؘؘ Sep 18 '12 at 12:12

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.