Logs, temp & system internals

How to Delete .DS_Store Files on Mac (and Stop Them Coming Back)

If you have ever unzipped a folder and found a mysterious .DS_Store file lurking inside, you are not alone. These hidden macOS metadata files are harmless on your own machine, but they litter shared drives, annoy teammates, and can build up into clutter over years of use. Here is how to delete .DS_Store files on Mac — in bulk, safely, and for good.

What Is a .DS_Store File?

macOS Finder creates a .DS_Store (Desktop Services Store) file inside almost every folder you open. It stores view preferences for that folder: icon positions, background color, sort order, and similar metadata. The name starts with a dot, making it invisible in Finder by default, but it appears on Windows machines and Linux systems — which is why they end up embarrassingly visible in shared project folders and Git repositories.

A single .DS_Store file is tiny (a few kilobytes). The problem is that macOS creates them everywhere — in every subfolder, on USB drives, and on network shares — so they accumulate into thousands of files over time.

Are .DS_Store Files Safe to Delete?

Yes, deleting .DS_Store files is safe. The worst that happens is that Finder forgets custom icon arrangements and view settings for the affected folders. macOS will recreate the files the next time you open those folders in Finder. You will not lose any documents, photos, or application data.

How to Delete .DS_Store Files on Mac Using Terminal

The fastest way to remove .DS_Store files from a specific location is with the find command. Open Terminal (Applications → Utilities → Terminal) and use the following.

Delete .DS_Store from a single folder and all its subfolders

find /path/to/folder -name ".DS_Store" -delete

Replace /path/to/folder with the actual path. For example, to clean your home directory:

find ~ -name ".DS_Store" -delete

Delete .DS_Store files from the entire Mac

To sweep your whole system you need elevated privileges, because some directories are protected:

sudo find / -name ".DS_Store" -delete 2>/dev/null

The 2>/dev/null part suppresses permission-denied warnings for system directories you cannot touch anyway. This command is safe to run, but it will take a few minutes on a full disk and will prompt you for your administrator password.

Preview before deleting (dry run)

If you want to see what will be removed before committing, drop -delete and just print the paths:

find ~ -name ".DS_Store" -print

How to Stop .DS_Store Files Appearing on Network and USB Drives

The most common complaint is .DS_Store files showing up on network shares, NAS volumes, and USB drives where other people — or other operating systems — can see them. macOS has a built-in preference to disable this behavior.

Disable .DS_Store on network volumes

  1. Open Terminal.
  2. Run the following command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
  1. Log out and log back in (or restart) for the change to take effect.

This setting applies to SMB shares, AFP volumes, WebDAV mounts, and other network file systems. It does not stop Finder from writing .DS_Store to local drives or USB volumes — macOS does not provide a built-in toggle for those.

Undo this setting

If you ever want to revert:

defaults delete com.apple.desktopservices DSDontWriteNetworkStores

What about USB and external drives?

There is no Apple-supported defaults key to suppress .DS_Store on removable drives universally. The practical workarounds are:

  • Format USB drives as ExFAT or NTFS — Finder still writes .DS_Store to them, but you can run the find … -delete command before ejecting.
  • Add .DS_Store to a .gitignore (or a global ~/.gitignore_global) so they never sneak into commits.
  • Use a script or a cleaning tool to sweep the drive before you hand it off.

Add .DS_Store to Your Global Git Ignore

For developers, the best long-term fix is a global gitignore so you never accidentally commit these files again:

# Create or append to your global gitignore
echo ".DS_Store" >> ~/.gitignore_global

# Tell git to use it
git config --global core.excludesfile ~/.gitignore_global

Bulk Removal: Terminal vs. a Cleaning Tool

Method Scope Effort Risk
find ~ -name ".DS_Store" -delete Home folder Low (one command) Very low — only removes metadata
sudo find / -name ".DS_Store" -delete Whole Mac Low (one command + password) Very low — safe as above
Finder manual search Limited High (repetitive) Very low
Crumb Clean or Duplicates Whole Mac or selected folders Very low (one click) Very low — shows what will be removed

The Terminal approach is perfectly adequate for most people. If you also want to reclaim space from caches, logs, and other system clutter in the same session, download Crumb — its one-click Clean and Duplicates sweep will catch stray .DS_Store files alongside the rest of the noise, without you needing to string together multiple commands.

What You Should Not Do

  • Do not delete .DS_Store inside system folders manually. The find -delete command already handles permissions gracefully. Manually digging into /System or /Library and deleting files there is unnecessary and potentially disruptive.
  • Do not use third-party "cleaner" apps that promise to delete system files you have never heard of. .DS_Store removal is safe; deleting random Library files because a tool flags them as "junk" is not.
  • Cleaning is permanent. There is no Recycle Bin for files removed with find -delete. The command bypasses Trash. Run a dry-run first if you are uncertain.

Keeping .DS_Store Clutter Under Control Long-Term

A few habits that prevent .DS_Store files from becoming a recurring headache:

  • Set the DSDontWriteNetworkStores preference once and forget it.
  • Add .DS_Store to your global gitignore.
  • Run find ~ -name ".DS_Store" -delete before zipping a folder you plan to share.
  • Schedule a periodic sweep of external drives before ejecting them.

Summary

.DS_Store files are a benign macOS quirk that become a nuisance when they escape onto shared drives or version control. The find . -name .DS_Store -delete command removes them instantly, the DSDontWriteNetworkStores default stops new ones appearing on network volumes, and a global gitignore keeps your repositories clean. None of these steps require third-party software — but if you want to roll .DS_Store cleanup into a broader disk tidy-up, Crumb handles it as part of a single pass.

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

What is a .DS_Store file on Mac?
A .DS_Store (Desktop Services Store) file is a hidden file that macOS Finder automatically creates inside folders to store view preferences such as icon positions and sort order. It is harmless on your own Mac but becomes visible on Windows, Linux, and shared network drives.
Is it safe to delete .DS_Store files?
Yes, deleting .DS_Store files is safe. You may lose custom Finder view settings (like icon arrangements) for the affected folders, but macOS will recreate the files the next time you open those folders. No documents or application data are affected.
How do I delete all .DS_Store files on my Mac using Terminal?
Open Terminal and run: find ~ -name ".DS_Store" -delete to remove them from your home folder. To sweep the entire Mac, use: sudo find / -name ".DS_Store" -delete 2>/dev/null (requires your administrator password).
How do I stop .DS_Store files from being created on network drives?
Run this Terminal command: defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true — then log out and back in. This tells macOS not to write .DS_Store files to network shares, NAS volumes, and similar remote file systems.
Can I stop .DS_Store files from appearing on USB drives?
There is no built-in macOS setting to prevent .DS_Store creation on USB or removable drives. The practical workaround is to run find /Volumes/YourDrive -name ".DS_Store" -delete before ejecting the drive, and to add .DS_Store to your global .gitignore so it never enters version control.