Is it safe to delete .DS_Store files?
- Yes. A
.DS_Storefile only remembers how Finder shows its folder: the view, where icons sit and similar settings. None of your files are inside it. - What it costs you: that folder opens with Finder’s default view until you arrange it again. Each file is a few kilobytes, so there’s no real space to win.
- Does it come back? Yes. Finder writes a new one when it opens the folder again, so clearing them is mainly for folders you share.
- SiftMac’s verdict: Rebuilds
1. What it is
The name stands for Desktop Services Store. Finder creates one in folders it opens and keeps that folder’s view options, icon positions and other visual information in it. It’s hidden on a Mac, which is why most people only meet it somewhere else: on a USB stick plugged into a Windows PC, in a zip file from a Mac user, on a network share, or committed to a Git repository.
It isn’t malware and it doesn’t mean anything is wrong. It’s also not where tags, dates or the files’ contents are kept; those stay with the files themselves.
2. Where it is
In nearly every folder Finder has opened: on your Mac, on external drives and on network shares. To see them in Finder, press ⇧⌘. (Shift-Command-period) to show hidden files, and the same keys again to hide them. To list the ones in a folder and its subfolders from Terminal:
find ~/Documents -name .DS_Store -type f
3. How big it gets
Tiny: a few kilobytes each, so even thousands of them come to megabytes. To count the ones in your home folder, then add up their size:
find ~ -name .DS_Store -type f 2>/dev/null | wc -l
find ~ -name .DS_Store -type f -exec du -k {} + 2>/dev/null | awk '{s+=$1} END {print s " KB"}'
4. How to delete them safely
On your own Mac there’s no reason to hunt them down. Clear them from a folder you’re about to share, a drive that goes into another device, or a code repository:
- One folder and everything in it: in Terminal, run the command below with your folder’s path in place of the example. It removes only files named exactly
.DS_Store. - A USB drive or SD card: close any Finder window showing it, run the same command on
/Volumes/followed by the drive’s name, then eject it. - A Git repository: add
.DS_Storeto Git’s global ignore file so it’s never committed again, and remove any already committed withgit rm --cached .DS_Store.
find /Volumes/MyDrive -name .DS_Store -type f -delete
mkdir -p ~/.config/git && echo .DS_Store >> ~/.config/git/ignore
Git uses ~/.config/git/ignore as its global ignore file by default, unless core.excludesFile or XDG_CONFIG_HOME points somewhere else. For network shares, Apple documents a setting that stops Finder using .DS_Store files on SMB shares; log out and back in after running it:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
Apple presents it as a way to make browsing a share faster; folders there then list in plain alphanumeric order. Run it again with FALSE at the end to undo it.
5. What happens afterwards
- The folder opens with Finder’s default view; the view, icon positions and sort order you chose there are forgotten.
- Finder writes a fresh
.DS_Storeas soon as it opens the folder again. - Files, names, tags and dates don’t change.
- With Apple’s network setting on, folders on SMB shares always open in plain alphanumeric order.
Questions
Is .DS_Store a virus?
No. It’s a normal hidden file Finder makes on every Mac. It only looks suspicious on Windows, where a dot at the start of a name doesn’t hide a file the way it does on a Mac.
Why are there .DS_Store files in a zip someone sent me?
The folder was zipped on a Mac with its hidden files included. They’re safe to delete after unzipping.
Can I stop Finder making .DS_Store files on USB drives?
Apple only documents a switch for network shares. For a USB drive, the practical way is to clear them with the find command just before you eject it.
Should .DS_Store be in .gitignore?
Yes. Put it in your global ignore file once, as above, and every repository on your Mac ignores it, so it never ends up in a commit.
How SiftMac handles it. SiftMac doesn’t list .DS_Store files, since there’s no space in them to get back. It ignores them on purpose, though: when it judges whether a project has been touched, it skips .DS_Store, because Finder rewrites it just from browsing, and it leaves it out of the Trash list.
Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works