How to prevent Mac OS X creating .DS_Store files on non Mac (HFS) Volumes?
If you are sharing the NTFS partition over a network, using SMB or some such, you can turn it off.
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Apple tech bulletin "How to prevent .DS_Store file creation over network connections". I have not verified that this still works with Snow Leopard.
I use this I set it up once when I got annoyed with the same problem. This method make the system do it all automatically.
Create a script called Remove_Hidden_Files.sh by opening terminal and for example cd ~/Documents and type touch Remove_Hidden_Files.sh
Using vi create the script. In Terminal type
vi Remove_Hidden_Files.sh
-
Press "I" to get in to insert mode and type the following (Hint to get # press alt and 3)
#!/bin/bash # Removing the hidden files from my drive using the find command. Change xxx to the name of your external volume or path you wish to run the command on. # the -mount will stop the find command going to other volumes other than specified. find -x /Volumes/(xxx) -mount -name '.DS_Store' | xargs rm -rf find -x /Volumes/(xxx) -mount -name '.Spotlight-V100' | xargs rm -rf find -x /Volumes/(xxx) -mount -name '.Trashes' | xargs rm -rf find -x /Volumes/(xxx) -mount -name '._.Trashes' | xargs rm -rf find -x /Volumes/(xxx) -mount -name '.fseventsd' | xargs rm -rf
Press escape to get out of insert mode and hold shift and press
:
Type
wq!
and then press enterMake the script executable
chmod 775 ~/Documents/Remove_Hidden_Files.sh
Test this out to make sure it works. You can easily do this by opening terminal and type cd /Volumes/(xxx) press enter and then ls -la to list all the files and you should see a .DS_Store if not navigate with the finder to the volume and then repeat the command and you should see one there.
Open another terminal by pressing command key and N
Type
cd ~/Documents
Type
sh Remove_Hidden_Files.sh
Go to the other terminal window and check the .DS_Store files are removed.
-
Create a launch daemon. This means to run automatically so you don't have to do anything.
Best way is to download lingon
Create a daemon for you user account and call it com.remove_hidden_files.Launchd
In the command box type
sh ~/Documents/Remove_Hidden_Files.sh
You can either type in the path or browse to it /Volumes/(xxx)
Reboot the machine and try it out
Note if you rename your external drive, use a different named drive or path you will need to change the script.