04 December 2017

Prevent apple OS from creating .DS_Store and other bullshits

I don't think I have to explain about that. Everyone that had to admin an ecosystem that have one or more apple users know how this can be a nightmare in many different scenarios (specially because at some point, MacOS doesn't care even to hide the files anymore when dealing with network shares, external drives and so on, how nice).

Well... this needs to be applied with the MacOS:

Prevent MDS from attempting to Index
sudo touch /Volumes/volume_name/.metadata_never_index

Disable Indexing AND Searching of Volumes (if necessary)
sudo mdutil -i off -d /Volumes/volume_name

Delete existing Spotlight Index (if necessary, to start over, whatever fits you)
sudo rm -rfv /Volumes/volume_name/.Spotlight-V100
sudo rm -rfv /.Spotlight-V100


Disable creating '.DS_Store' bullshit on USB volumes
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Disable creating '.DS_Store' bullshit on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

Now that you've cleaned the mess, remove this bullshit from your drives:
find /path/you/want/to/clean/ -name ".DS_Store" -depth -exec rm {} \;