Delete All .DS_Store Files from Mac OS X

Jul 5, 2012 - 15 Comments

DS_Store Files in Mac OS X

DS_Store files are hidden system files that reside within almost every folder of Mac OS X, they contain folder-specific information and settings, like what view to use, icon size, and other metadata pertaining to their directory. Though they’re invisible to the average user, if you’re sharing with a Windows PC or have hidden files shown in Finder you’ll see them in every folder, and if you’re trying to force a change like which view to use across all directories in Finder, you may discover the .DS_Store files are in the way.

The method described below will delete every single DS_Store file from a Mac OS X volume.

How to Delete All DS_Store Files from a Mac

  1. Launch Terminal, found in /Applications/Utilities/
  2. Type the following command exactly:
  3. sudo find / -name ".DS_Store" -depth -exec rm {} \;

  4. Enter the administrator password when asked – it won’t be visible when typing which is standard for the command line
  5. Let the command run, it will find all instances of .DS_Store and delete them

You can also go a step further and use a defaults write command to disable .DS_Store creation which can help to avoid clutter on networked drives.

If your annoyance with DS_Store stems from networking, you may notice that Windows PC’s have similar metadata files in all directories called “Thumbs.db“, those can also be removed separately by using Spotlight.

This is a handy tip from Adobe, of all places. Adobe also shows how to use crontab to schedule the deletion of .DS_Store files, but if you delete them once and disable their creation you shouldn’t need that functionality. Thanks for the tip idea Andy!

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Tips & Tricks, Troubleshooting

15 Comments

» Comments RSS Feed

  1. Pedro says:

    An advice, copy-past the command line…
    I typed it myself and forgot the -name and now everything got deleted………… my god :X

  2. Alberto I says:

    What is the meaning to delete these? They will be recreate after a restart or o relog, no?

  3. Mark says:

    Or just use dot_clean which was designed for this on the root of the drive.

  4. Tony says:

    This may seem like a silly question but I am a relatively new user to OSX and am wondering what the purpose would be in deleting these files other than some housekeeping which I am all for. Are there any performance benefits etc?

    • Will says:

      If you don’t have a compelling reason to delete these files (primarily, networking with a lot of Windows PC’s), you do not need to do so. There is no performance benefit and they are recreated by OS X to store preference information.

      Definitely not necessary for 99% of users.

  5. Bruno Gama says:

    there’s no reason to do that, finder will recreate everything.

    but, if you are justifying to delete ds_store because the windows sharing, erase all files from your local user (~ instead /) or the shared folders in the network.

    you could even create a cron or launchd task to do the job.

  6. Chris says:

    You might also want to do this for ._.DS_Store files as well (I’ve noticed a lot of these on network drives).

    Find also runs a lot faster if you allow its exec routine to group multiple files into the same command with \+ instead of \; E.g.

    find / \( -name .DS_Store -o -name ._.DS_Store \) -exec rm -f {} \+

    The -depth flag is unnecessary in this use case.

  7. Jeff says:

    There’s an app for that: http://itunes.apple.com/us/app/ds-store-remover/id476237254?mt=12
    (free on the mac app store)

    I wouldn’t recommend non technical people to execute:
    sudo find / -name “.DS_Store” -depth -exec rm {} \;
    It is asking for trouble…

  8. Lauri Ranta says:

    As Chris said, the -depth option isn’t needed.

    OS X’s find also has a -delete flag:

    sudo find / -name .DS_Store -delete

    > An advice, copy-past the command line…
    > I typed it myself and forgot the -name and now everything got deleted………… my god :X

    This should be repeated, don’t forget the -name flag.

  9. Pedro says:

    Toke me some time but now all is restored ehhe
    Good think i noiticed what was happening fast xD

  10. James Ludtke says:

    I some times zip folders for transmission to Windows users. How can I delete the .DS file in just that folder before zipping it. I suppose that if I do not change any windows setting before zipping, the.DS file is not recreated in that folder.

  11. mikey says:

    Do NOT delete these if you are just using your OS X system, or shares on your network. (You can delete them, if they are only held on a non-OS X system, eg. Win.)

    a) They actually do a job.
    While it’s an *aspiration* that Apple use “extended file attributes” for these current per-folder settings; they are NOT yet! Hence Finder needs these files to keep Spotlight data and all your other folder settings you have set as a user yourself, actually working.

    b) They get re-created anyway by Finder/PathFinder.

    c) They are harmless.
    And while they seem like cruft, they’re not on OS X: they do a job.
    They do not override folder specific settings, unless you *specifically ask them to* by using OS X’s GUI (or command line) to do so.

  12. Vlad Didenko says:

    You may want to explain your users when to use the -x option. Otherwise scanning mounted shares may take forever.

  13. MisterSoushi says:

    I put the code in and the password came out and I can’t type my password or any other letters. All I can do is press the enter button and that didn’t help at all.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates