Friday, January 4, 2013

How to recursively remove .DS_Store files on Mac OS X

The following command will remove all .DS_Store files in a directory where it is executed as well as that particular directory’s subdirectories:
find . -name '*.DS_Store' -type f -delete

Why would you want to remove .DS_Store files? The .DS_Store files store Finder-specific preferences concerning the display of each of your folders. Removing these files is an easy way to reset your display preferences. Also, if you’re moving files between your Mac and another operating system such as Windows or Linux these files can cause unexpected problems and should be removed prior to transfer.
This command works on Mac OS X (both 10.4 Tiger and 10.5 Leopard) and Unix-type operating systems such as Linux. What follows is a step-by-step guide on how to properly use this command on Mac OS X.

Directions on how to recursively remove .DS_Store files on Mac OS X
  1. Open up the Terminal application (/Applications/Utilities/Terminal.app).
  2. Find the directory/folder that you wish to recursively delete the .DS_Store files from. For this tutorial let’s pretend you want to delete all the .DS_Store files in your Pictures folder and every folder inside that folder. Type this command into Terminal (without pressing the return key):
    cd
  3. Then drag and drop your Pictures folder onto the Terminal window. The cd command should now look something like this–where ariadoss is your Mac’s “short name” (i.e. your username):
     cd /Users/jcruz/Pictures
  4. Press the return/enter key on your keyboard.
  5. Type the following command into Terminal and press return to execute it:
    find . -name '*.DS_Store' -type f -delete

Congratulations the .DS_Store files have been deleted! Please note that this command will just delete existing .DS_Store files; your Mac will continue to create them

If you wish to disable the creation of .DS_Store files on external volumes type the following command into Terminal and hit enter (you may need to logout or restart your computer after executing this command):
defaults write com.apple.desktopservices DSDontWriteNetworkStores true


No comments:

Post a Comment