everyday mac tools

Stop .DS_Store files appearing on external and network drives

· 6 min read

A .DS_Store file is where Finder saves how a folder looks: view mode, sort order, icon positions, window size. Finder writes one in any folder it displays, including folders on a colleague’s server and on your backup drive. macOS has a supported setting to stop that on network volumes, a newer one for USB volumes, and neither of them removes the files that are already written.

What the file is and why it keeps coming back

The leading dot makes it invisible in Finder, which is why most Mac users never see one. It is per folder, not per drive: open a folder, resize the window, switch to List view, sort by date or drag an icon somewhere deliberate, and Finder writes a .DS_Store there to remember it.

On your own Mac this is harmless and mildly useful. It becomes a problem the moment the folder is shared:

  • A colleague on Windows or Linux sees the files in the share and asks what they are.
  • A folder uploaded to a website or a build system carries one in every directory.
  • A version control diff fills up with them.
  • A zip archive you send to a client contains a copy in each folder.

Nothing breaks if they are deleted. Finder writes a new one when it next needs to remember something, and the folder reverts to your default view settings in the meantime.

Stop them on network shares

This is the setting Apple documents, and the closest thing to an official answer:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

Log out and back in. It covers volumes mounted over the usual file sharing protocols, which is what people mean by a network drive: a company server, a network attached storage box, a shared folder on another Mac.

Two honest limits. It stops your Mac writing new ones; the files already on the share stay until somebody deletes them. And every other Mac connecting to that share carries on writing its own until it gets the same setting. On a share used by a team, this is a change to make once on every Mac, not on the server.

Stop them on USB and other external drives

Recent macOS versions (Sonoma and later) recognize a companion key for locally attached volumes:

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Log out and back in, then test it rather than assuming. Plug the drive in, open a folder on it in Finder, change the view, and list the folder in Terminal:

ls -a /Volumes/DRIVE/Folder

Replace DRIVE with the drive’s name as it appears in Finder. If no .DS_Store appears, the key took.

On older macOS versions, writing this key does nothing and there is no supported way to stop .DS_Store on a locally attached disk. If you are on an older version, plan on clearing the files periodically instead of preventing them.

Clear the ones already there

Look before you delete. This lists every one on a drive without touching anything:

find /Volumes/DRIVE -name ".DS_Store" -type f -print

Quote the whole path if the drive’s name contains a space. Read the list, and when it is what you expect, run the same command with -delete:

find /Volumes/DRIVE -name ".DS_Store" -type f -delete

That deletion is immediate and does not go through the Trash. What you lose is per-folder view settings on that drive and nothing else. Keep the name exact, keep the path pointed at the drive you mean, and do not add wildcards: find with -delete does precisely what you tell it, with no confirmation step and no undo.

If you would rather see them first, show hidden files in Finder and hide them again covers Command-Shift-Period, which reveals dot files in any Finder window so you can delete them by hand.

The other invisible files people blame on .DS_Store

Four different things, four different fixes. Telling them apart saves a lot of guessing.

._ files (AppleDouble). These appear when a file carrying extended attributes or a resource fork is copied to a filesystem that cannot store them: exFAT, FAT32, many network shares. dot_clean /Volumes/DRIVE merges them back into their files where it can. Formatting the drive as APFS or Mac OS Extended avoids them entirely, at the cost of the drive no longer being readable on Windows without extra software.

.Spotlight-V100. The search index for that volume. Prevent it by adding the drive to Spotlight’s privacy list in System Settings, in the Spotlight settings (named Siri & Spotlight on some macOS versions). The trade is that searching that drive stops working.

.fseventsd. The log of file changes that Time Machine and similar tools read. Leave it alone; it is recreated and it is doing a job.

.Trashes. The per-volume Trash. Files you delete from an external drive live there until the Trash is emptied with the drive connected.

What you give up

Turning off .DS_Store on a volume means Finder forgets per-folder settings there. Every folder opens in your default view, with the default sort, and icon positions you arranged by hand are not preserved. For a shared server, a scratch disk or a drive that mostly gets read on other systems, that is a fair trade.

Your global preferences still apply, because those are stored per user rather than per folder. Keeping folders at the top when Finder sorts by name is one of them, and so is the default view you set with Use as Defaults in View Options. What disappears is the per-folder override, not the baseline.

Doing it with a switch

Both keys are ordinary macOS settings with no interface anywhere in System Settings. Mainspring (https://trymainspring.com/) exposes the external drive one as a power-up labeled no .DS_Store on external drives, and it records the previous value before changing anything so one click puts it back. It also groups related Finder settings into recipes that apply and revert as a set, which is the part worth having if you are changing several at once.

If you are only making this one change, the command above is enough and an app is not needed. The reason to want the app version is a Mac you set up for someone else, where being able to hand back every default in one click matters more than the command being short. What defaults write does and how to undo one safely covers the manual version of the same idea.

Questions

Is it safe to delete .DS_Store files? Yes. They hold view settings and nothing else. No document, permission or piece of metadata about your files lives in them. Finder writes new ones as needed.

Will this stop them appearing in a folder that syncs to the cloud? No. A sync folder lives on your internal disk, so neither key applies to it, and there is no supported setting that stops Finder writing .DS_Store in a local folder. The practical answer is an ignore rule in whatever does the syncing.

Can I stop them on the internal drive? There is no supported way, and it is not worth pursuing. On the drive where you actually work, per-folder view settings are the feature rather than the nuisance.

Why does my colleague see these when I never do? Finder hides files whose names begin with a dot. Windows Explorer and most Linux file managers do not, so a folder that looks clean on your Mac arrives on their machine with an extra file in every directory.