macOS: Delete .DS_Store files to reset folder settings

The following command will:

  • Only delete .DS_Store files
  • Only in the folder you choose (not its subfolders)
  • Not require your password
  • Not touch system files

In order to run the following commands, the Terminal will have to have access to your storage devices. Read this blog post to learn how to enable Full Disk Access for Terminal.

Step-by-Step Instructions:

  1. Open Terminal
    Press Command + Space, type Terminal, then press Return.
  2. Type find, then a space. Don’t press Return yet.
  3. Drag the folder into the Terminal window.
    This automatically inserts the correct file path — even if the path contains spaces or it’s on an external drive.
    For example, it might look like this:
    find /Volumes/My\ External\ Drive/Some\ Folder
    (You’ll see backslashes \ before spaces — that’s normal.)
  4. Complete the command by adding this to the end:
    -maxdepth 1 -name .DS_Store -delete
    So the full command might look like:
    find /Volumes/My\ External\ Drive/Some\ Folder -maxdepth 1 -name .DS_Store -delete
  5. Press Return. That’s it!
    If there’s a .DS_Store file in that folder, it will be deleted instantly. You won’t get a confirmation message — Terminal just does it.

Quick note about paths:

In the Terminal, spaces are used to separate parts of a command — like the command itself from the options and file or folder names. So if a folder is called My Folder, typing it without any special formatting (like My Folder) will confuse the Terminal into thinking you’re referring to two separate things (“My” and “Folder”). To fix this, you can escape the space with a backslash (\), like this: My\ Folder. This tells the Terminal, “treat the space as part of the name.” Another option is to wrap the entire path in quotes, like "My Folder", which also works. But important: don’t combine the two — a backslash inside quotes (like "My\ Folder") will not work and will actually break the command. Use either backslashes or quotes, but not both.

Examples:

Deleteing “.DS_Store” from the Desktop folder:
find ~/Desktop -maxdepth 1 -name .DS_Store -delete

Deleteing “.DS_Store” from the Documents folder:
find ~/Documents -maxdepth 1 -name .DS_Store -delete

External drive folder (just drag the folder in):
find /Volumes/My\ USB\ Stick/Project\ Files -maxdepth 1 -name .DS_Store -delete

What this does NOT do:
It does not delete anything else.
It does not go into subfolders (so it’s very safe).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.