Sabtu, 31 Maret 2018

Mac OS X: How to remove .DS_Store files

Do you suddenly have files or icons named .DS_Store appearing in your folders or on your desktop?  And you have no idea how they got there or how to handle them? If you try and delete these particular files, they simply reappear as soon as you delete them or put them into the trash.  So, how do makes those darn .DS_Store files disappear?Do you suddenly have files or icons named  Mac OS X: How to remove .DS_Store files



Related Articles



All About .DS_Store Files


.DS_Store (or Desktop Services Store) are hidden cache files created by Mac OS. And if they don’t exist, your OS creates them. These hidden files are automatically created by your mac’s Finder in your computer’s directories. They contain information about your system configuration and settings, such as icon size and other directory metadata. If by chance or accident, you upload these .DS_Store files along with other files, the files may release information about your computer.


Your Mac places a .DS_Store file into every folder you have open, automatically. If you suddenly see .DS_Store files and unable to get rid of them, you probably accidently activated Show All Files.  Though .DS_Store files are invisible to the average user, if you’re sharing with a Windows PC or have hidden files shown in Finder, you see them everywhere, in every folder.  You might even see a .ds_store icon on your desktop!  In all likelihood, you probably have no idea how the .DS_Store files got there in the first place, what they mean, or how to get them off your desktop or folder.


Don’t Delete .DS_Store Files (unless you have a very good reason)


If you don’t have a particular reason to delete these .DS_Store files (windows sharing might be a solid reason,) it’s best to leave them “as is.” There’s no performance benefit in deleting .DS_Store files. They are harmless files that don’t usually cause any problems. Remember that the .DS_Store file saves your personalized folder settings, such as your icon arrangement and column sortings. And that’s why you normally don’t want to delete them but rather HIDE them.


You can delete them, but they are recreated by OS anyway, primarily to store your preference information.


So for most of us, it’s best to just make .DS_Store files hidden once again  


Make Your .DS_Store files Hidden Again



  1. Launch Terminal by selecting Applications > Utilities

  2. Enter the following command: defaults write com.apple.finder AppleShowAllFiles -boolean false;killall Finder 

    1. You can also use the command: defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder



  3. Hit return, the Finder restarts and .DS_Store files (and other invisible files) are hidden againDo you suddenly have files or icons named  Mac OS X: How to remove .DS_Store files

  4. If your .DS_Store file is still visible, relaunch your Finder

    1. Use the keyboard shortcut Option+Shift+Command+Escape OR

    2. Open Finder

    3. Click the Apple menu while holding down the Shift key

    4. Click Force Quit Finder or use the keyboard shortcut Option+Shift+Command+EscapeDo you suddenly have files or icons named  Mac OS X: How to remove .DS_Store files




Unhide Your .DS_Store files


If you decide you want to unhide the .DS_Store File or any other invisible files, just use another (and very similar) terminal command


  1. Launch Terminal

  2. Enter the following command: defaults write com.apple.Finder AppleShowAllFiles TRUE;killall Finder

    1. Or use this command: defaults write com.apple.finder AppleShowAllFiles -boolean true;killall Finder 



  3. Press return and your Finder restarts, showing all those hidden files including .DS_Store

  4. If your hidden files or .DS_Store file did not reappear, relaunch Finder

    1. Use the keyboard shortcut Option+Shift+Command+Escape OR

    2. Hold the ⌥ (alt/option) and right-click on the Finder icon in your Dock

    3. Click Relaunch or use the keyboard shortcut Option+Shift+Command+Escape




If You Must Delete, Do It By the Book with Terminal


Do you suddenly have files or icons named  Mac OS X: How to remove .DS_Store files



Remove all DS_Store files



  1. Select Applications > Utilities and launch Terminal

  2. Enter the command: sudo find / -name “.DS_Store” -depth -exec rm {} \;

  3. When prompted for a password enter your OS Administrator password



Automatically remove DS_Store files periodically



  1. Select Applications > Utilities to launch Terminal.

  2. Enter the following UNIX command: sudo crontab -e

  3. When prompted for a password, enter your OS Administrator password

  4. In the vi editor, press the letter I on your keyboard once and enter the following command: 15 1 * * * root find / -name “.DS_Store” -depth -exec rm {} \;

    1. This crontab entry has the following format: <Minute> <Hour> <DayOfMonth> <Month> <DayOfWeek> <User Command>

    2. The system automatically runs the command at 1:15 AM every day. To configure the command for a different time, use different values



  5. To save the entry, press the Esc key once, then simultaneously press Shift+Z+Z


Note: If your computer is switched off, this command does not run