A script to clean my car radio’s media thumbdrive of hidden files upon ejecting from OSX.

I bought a car stereo for the first time ever, one of it’s many features is a USB connection on the faceplate. I bought the smallest thumb drive I could find, removed the plastic housing, and have left it permanently in the faceplate. It’s small enough that it doesn’t interfere with the protective case closing when I take it out of the car, which I do every time I stop the car.

I wrote this script while heading out the door to work (3minutes max) because I was tired of the head unit display “File Not Compatible” on non-MP3 files which mostly were hidden files automatically created by OSX upon a Finder window hitting the folder.

You’ll need to open a terminal window, change directory (cd) to where you want the script; I suggest the desktop as putting it on the thumbdrive will not allow the thumbdrive to dismount at the end of the script and some of the files will regenerate. Then I suggest using nano and entering `nano TD_dismount.sh` copy and paste the following hit Ctrl + X and Yes to the prompt. Then `chmod +x TD_dismount.sh` to make the script executable.

rm -rfd /Volumes/KD-AHD69/.Spotlight-V100
rm -rfd /Volumes/KD-AHD69/.TemporaryItems
rm -rfd /Volumes/KD-AHD69/.Trashes
rm -rfd /Volumes/KD-AHD69/._.TemporaryItems
rm -rfd /Volumes/KD-AHD69/._.Trashes
rm -rfd /Volumes/KD-AHD69/.fseventsd
rm -rfd /Volumes/KD-AHD69/.*
rm -rfd /Volumes/KD-AHD69/*/.*
rm -rfd /Volumes/KD-AHD69/*/*/.*
rm -rfd /Volumes/KD-AHD69/*/*/*/.*
rm -rfd /Volumes/KD-AHD69/*/*/*/*/.*
rm -rfd /Volumes/KD-AHD69/*/*/*/*/*/.*
sudo diskutil unmount /Volumes/KD-AHD69/

I’ve labeled the thumb drive the model number of the headunit, just make sure the thumbdrive is named something unique otherwise you might delete something on  a thumbdrive with the same volume name that you didn’t mean to delete; such as the trash directory which contained your last copy of your term paper which was coincidentally accidentally delete. The things you miss the most are the things you can’t recover.

This entry was posted in How To and tagged , , , . Bookmark the permalink.

One Response to A script to clean my car radio’s media thumbdrive of hidden files upon ejecting from OSX.

  1. Vi says:

    While I’m sure this custom script you wrote is d’omg awesome, I think I’m still floored that you bought a stereo for your car, lol.

Leave a Reply

Your email address will not be published. Required fields are marked *