Apple - How to stop OS X from writing Spotlight and Trash files to memory cards and USB sticks?

For just a particular mounted volume - like a flash drive called yourUSBstick in this example - these commands will remove existing cruft, stop Spotlight indexing now and in the future, stop the related fsevents logging, and disable the Trash feature.

mdutil -i off /Volumes/yourUSBstick
cd /Volumes/yourUSBstick
rm -rf .{,_.}{fseventsd,Spotlight-V*,Trashes}
mkdir .fseventsd
touch .fseventsd/no_log .metadata_never_index .Trashes
cd -

Other unfamiliar stuff you may still see you probably want to keep, like Apple double "._*" files and other Apple DS cruft relating to icons and window placement.


To keep Spotlight from indexing non system volumes, add /Volumes to the Privacy list in System Preferences > Spotlight.

/Volumes is the point in the file system where all non-system disks are mounted by default.

enter image description here


UPDATED March 2018 It seems my solution is not valid anymore, the solution that works right now is proposed by @ElmerCat in one of the answers below.

He is suggesting to use CleanMyDrive 2

Deprecated Solution

As I know you have 2 choices :

  1. TinkerTool (free)

alt text

  1. BlueHarvest (commercial)

alt text