Delete All .DS_Store Files from Mac OS X

Jul 5, 2012 - 29 Comments


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 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’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, thus it’d be reasonable to want to delete and remove ds_store files on a Mac.

The method described below will delete every single DS_Store file from a Mac OS X volume. As usual with the command line, it is for advanced users only, it is critical that you enter the syntax exactly as written otherwise you could delete other files.

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

DS_Store Files in Mac OS X

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!

If you know of any other handy tips for managing and dealing with DS_Store files then share them in the comments below!

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


» 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

    • Ellis says:

      I copy-pasted and now all my files were deleted. How did you recover them?

      • Todd says:

        You wanted to delete the .DS_Store files, so you deleted them, and now you want them back? What were you expecting to happen? What a strange thing.

        You can use Time Machine to restore your DS_STORE files if you want them back, or let them regenerate on their own.

        The tip from Adobe Software Inc to use sudo and rm is not the best idea. And if you don’t know the command line, don’t ever use it. Period.

  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:
    (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.

  14. Robert says:

    Rubbish. Ds_Store files cause a huge problem.

    If, like me, you try to copy a large number of files from one external hard drive to another it fails because of Ds_Store files.

    The copying process stops. So you come back to your mac having waited ages and lo and behold, it hasn’t done what you want. It simply stops the copying process. Completely hopeless.

  15. Christer says:

    Robert: Yes: Copying files between disks in a network (NAS) is a big problem.
    Using the new thunderbolt disks (DAS) as a substitute for those slow connections (NAS), is an ever greater problem.
    As these disks are treated as local disks, there is no way of stopping the DS_Store creations.
    The basic problem is the way Finder copies maps.

    This is one way of getting the error:
    1. Create a map and fill it with data in/on a NAS.
    2. Create some a local map with som extra maps.
    3. Look into these local maps to create DS_Store files.
    4. Copy te top local map into the NAS-map
    5. Copy the top NAS-map back to a local USB-disk.
    6. Move this USB-disk to another computer.
    7. Copy the USB-disk content back to a thunderbolt disk.
    ==> It will not work as the a “DS_Store” file already exists. !

    This is getting furious, as…
    even as you can find the problem, you can’t do anything to solve it !!!

    We need a simpler handling from Apple to show and fix this utterly annoying problem.

  16. Pramesh says:

    Hey, the .DS_Store files are not visible in my Mac, but whenever I upload a zip file (with multiple folders inside) on Google Drive, .DS_Store files appear in each and every folder.

    How may I solve this issue? I tried the “copy-paste this line” thing but it doesn’t seem to work.

    And, how long does the execution of copy-paste thing take in terminal?

  17. JAMES says:

    Whats the Password for DS-STORE????

  18. Johan says:

    The .DS_Store files are very annoying in copy operations.
    For example, I have 2 WD MyCloud 4 TB drives containing media files. Both drives are used as media server and serve the users in our household, in this case it was not an option to format the drives as dedicated Mac drives. When I start rearranging the media files I ended up in frustration because the .DS_Store files stopped copy and/or moving operations.

    I found on the internet a handy little Windows app (Ultracopier for Windows – that does the job. if it encounters file doubles it will ask you what to do with the file (replace-skip….) this little app saved my day.

  19. Giles says:

    When I try this operation I get:

    find: /dev/fd/3: Not a directory
    find: /dev/fd/4: Not a directory

  20. Giles says:

    It keeps running after the above notes, but then it stops with this:
    override rw-rw-r– root/admin for /Volumes/Backup Space/Backups.backupdb/GB’s G4 PB/2015-12-16-185712/Hard Drive/.DS_Store?

    I don’t know how to answer this.

  21. Ellis says:

    I was trying to do this to repair some corrupt .MOV files and afterwards everything on my external was deleted. Obviously I had no business messing with this stuff and now I’m screwed. Is there any way I can recover these files?

  22. hkChaos says:

    If you want to delete within a dir, use .

    1. See if these are the right files/dir to delete
    sudo find . -name “.DS_Store” -print

    2. Delete them
    sudo find . -name “.DS_Store” -exec rm {} \;

    3. Check if they are deleted
    sudo find . -name “.DS_Store” -print

    I do above steps before making an archive

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

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

Tips & Tricks


iPhone / iPad