Sweepfor Mac

Free up storage

What Are Those .DS_Store Files (and Should You Delete Them)?

What .DS_Store files actually do, when they cause problems, and how to stop macOS from creating them on shared folders and external drives.

6 min read

If you’ve ever opened a folder full of files in Windows after sending it from a Mac, you’ve probably seen them: tiny invisible files named .DS_Store, sitting in every directory like ghosts. Sometimes they cause real headaches — broken downloads on Linux servers, ZIP archives that look weird on Windows, version control noise.

So what are they actually for, and should you be deleting them?

What .DS_Store actually is

.DS_Store stands for “Desktop Services Store.” It’s a file Finder creates in every folder you open, to remember view preferences for that folder. Things like:

  • The folder’s view mode (icons, list, columns, gallery)
  • Custom icon positions if you’ve dragged things around
  • Sort order
  • Window size and position
  • Background colors or pictures (rare these days)
  • Custom column widths in list view

It’s tiny — usually 6-15KB. The dot at the start of the name makes it hidden in Finder by default; you’d never see it without explicitly toggling hidden files (Cmd+Shift+. in Finder).

The file is harmless on a Mac. macOS knows what to do with it. It’s only annoying when those files end up somewhere they’re not wanted.

When .DS_Store becomes a real problem

Three scenarios where it actually matters:

Sending folders to non-Mac users. Zip a folder on your Mac, send to a Windows user, and they see a .DS_Store file (visible on Windows) in every subfolder. Looks unprofessional. Sometimes confuses them.

Web hosting and FTP uploads. If you upload a website folder to a web server, the .DS_Store files come along. They can show up in directory listings, cause weird issues with tools that expect specific files, or just clutter the server.

Network shares and cloud sync. When you mount a network drive (SMB or NFS) on your Mac, Finder eagerly creates .DS_Store files there too. These can pollute shared folders that lots of people use, and on some systems the files cause sync conflicts.

Git and version control. If you don’t have .DS_Store in your .gitignore, you’ll commit them constantly without realizing. Most teams add it as the first line of their global gitignore.

Should you delete them locally?

Honestly, no, not really. If you delete them on your Mac, Finder will recreate them the next time you open the relevant folder. You’d be deleting forever and never gaining anything.

If you’re tight on storage, the math doesn’t help either. Even on a Mac with 100,000 folders (extreme), .DS_Store files total maybe 1.5GB at the high end. Versus the 40-100GB sitting in caches and snapshots, it’s not the right place to spend cleanup effort.

The exception is when you’re preparing a folder to send somewhere — to a client, to a server, to a non-Mac user. Then yes, clear them out before zipping.

How to delete .DS_Store from a folder

Quick command to wipe .DS_Store from a folder and all its subfolders:

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

Replace /path/to/folder with the actual path. The -delete flag removes them silently. To preview without deleting first:

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

For the entire home folder (rarely needed, but if you really want to):

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

The 2>/dev/null hides “permission denied” errors for folders you can’t access. Will run for a few minutes on a busy home folder.

Skip the manual huntSweep finds every cache, log, and forgotten file in seconds — and only removes what you OK. Download Sweep free →

Stop creating them on network drives

This is the high-value setting nobody knows about. To tell macOS not to create .DS_Store files on network shares:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

Then log out and log back in. From that point on, when you mount any SMB/AFP/NFS share, Finder won’t drop .DS_Store files into it.

Same trick for USB drives:

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

These two settings together solve the most annoying real-world .DS_Store problems — you don’t pollute shared network folders, and you don’t pollute USB drives you’re sharing with non-Mac users.

To revert if needed:

defaults delete com.apple.desktopservices DSDontWriteNetworkStores
defaults delete com.apple.desktopservices DSDontWriteUSBStores
Tip: If you frequently send folders to clients, just keep a Quick Action set up. Right-click → Quick Actions → "Delete .DS_Store" can be created in Automator with a one-line shell script. Once configured, cleanup is one right-click.

A .gitignore template for developers

If you’re a developer using a Mac, this is a must-have line in your global gitignore:

.DS_Store

To set up a global gitignore (applies to every repo):

git config --global core.excludesfile ~/.gitignore_global
echo ".DS_Store" >> ~/.gitignore_global

After that, no Mac developer on any team has to think about .DS_Store files in their git history again.

If they’re already in your repo’s history (because someone forgot to gitignore them), you can purge them from the working tree:

find . -name ".DS_Store" -print0 | xargs -0 git rm --ignore-unmatch
git commit -m "Remove .DS_Store"

Note this only removes them from the current commit forward. Cleaning them out of historical commits requires git filter-repo or similar — usually not worth the effort.

While we’re on hidden Mac files in shared folders, there are a few siblings worth knowing about:

  • ._filename — these “AppleDouble” files appear when you save Mac files (with metadata) onto a non-Mac filesystem like FAT32 or exFAT. The metadata gets split into a separate file. Annoying, sometimes unavoidable.
  • .Trashes — every drive (including external) gets one. It’s where deletions go on that drive. Don’t manually delete this folder; macOS recreates it anyway.
  • .fseventsd — File System Events daemon data. macOS uses it to track changes for Spotlight and Time Machine. Don’t touch.
  • .Spotlight-V100 — Spotlight’s index for the drive. Deleting forces a reindex (slow), but doesn’t break anything.

For the ._filename problem specifically, the fix is similar to the network shares trick:

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Already covers most cases. For the AppleDouble files specifically:

dot_clean /Volumes/DRIVENAME

Where DRIVENAME is the external drive. This consolidates AppleDouble metadata into the original file when possible, deleting the separate ._ files.

When to actually care

For most users, .DS_Store files are completely fine — invisible, harmless, irrelevant. The cases where they actually need attention:

  1. You share folders with Windows or Linux users regularly
  2. You manage a web server or FTP destination from a Mac
  3. You’re a developer who hasn’t set up a global gitignore yet
  4. You use shared network drives in an office with non-Mac users
  5. You’re zipping folders to send to clients

If none of those apply, ignore them. They’re a quirk of macOS that exists for a reason — Finder genuinely uses them — and the storage cost is microscopic.

If you’re frustrated by them showing up everywhere, the network/USB defaults commands above are the highest-impact fix. Most other “delete .DS_Store” advice you’ll find online treats them like a security or performance issue, which they’re not. They’re just slightly nosy.

← Back to all guides