DS Store Files on Mac: What They Are & How to Delete
In this article
If you've ever connected an external drive or USB stick to a Mac and then looked at it on a Windows PC, you've probably seen a file called .DS_Store. It looks like clutter, and many people assume it's a virus or a sign of corruption. It's neither. A .DS_Store file is a harmless but persistent metadata file that macOS creates automatically in every folder you open with Finder. This article explains exactly what these files are, why they exist, why you might want to delete them, and the safest ways to do so.
What Exactly Is a .DS_Store File?
.DS_Store stands for Desktop Services Store. It's a hidden file that macOS uses to store custom view settings for each folder. That includes things like:
- Icon positions and sizes
- Whether the folder is shown as icons, list, columns, or gallery view
- Sort order (name, date, size, kind)
- Background color or image of the folder window
- Window size and position
Every time you open a folder in Finder, macOS checks if a .DS_Store file exists in that folder. If it doesn't, it creates one. If it does, it updates it when you change the view. The file is written in a binary format that only macOS understands. Windows and Linux ignore it, but they still show it because it's not hidden on those systems.
The file is named with a leading dot, which is the Unix convention for hidden files. On macOS, Finder hides it by default. On Windows, the dot doesn't hide it, so you see it as a normal file. That's why it's so visible when you plug a USB drive into a PC.
Why Does macOS Create Them Everywhere?
macOS creates a .DS_Store file in every folder you open in Finder, including folders on external drives, network shares, and even your Desktop and Documents. It's not a choice you can turn off in System Settings. The system does it automatically to preserve your view preferences between sessions.
The reason it appears on external drives is that macOS treats them like any other folder. When you open the root of a USB stick in Finder, it writes a .DS_Store there. If you then copy files to that drive, the .DS_Store comes along. It's not a virus and it doesn't contain your personal data—it only stores view settings, not file contents.
There is no official Apple setting to disable creation globally. Some third-party tools claim to do it, but they work by deleting the file after it's created or by setting a specific flag. In practice, on a modern Mac, you can't prevent the creation entirely without using a command-line tool that runs in the background.
Should You Delete .DS_Store Files?
For most people, the answer is yes, but only when they cause a problem. Deleting a .DS_Store file is safe because macOS will simply recreate it the next time you open that folder. You lose nothing except custom view settings for that specific folder.
Here are the main reasons to delete them:
- You're sending files to a Windows user. The .DS_Store file is useless to them and can look suspicious.
- You're zipping a folder to share. The archive will contain .DS_Store files, which can confuse less technical recipients.
- You're committing code to a repository. Developers often add .DS_Store to .gitignore to keep it out of version control.
- You're copying files to a network drive or cloud storage. The files are clutter and can count against syncing quotas.
- You're troubleshooting a folder that behaves oddly. A corrupted .DS_Store can cause Finder to show wrong icons or views. Deleting it forces macOS to rebuild it.
If you're just using your own Mac and never share files, you can safely ignore them. They take up almost no space (usually a few kilobytes) and you'll never see them.
How to Delete .DS_Store Files Safely
There are several ways to remove .DS_Store files, from manual deletion to command-line commands. Choose the method that matches your comfort level.
Method 1: Delete a Single File in Finder
To delete one .DS_Store file on an external drive or a folder you can see:
- Open Finder and navigate to the folder containing the .DS_Store file.
- Press Command + Shift + . (period) to show hidden files. This is a toggle; press it again to hide them.
- Locate the file named .DS_Store (it will appear dimmed).
- Right-click it and choose Move to Trash, or drag it to the Trash.
- Empty the Trash to free the space.
This works for a single file but is impractical if you have dozens on a drive.
Method 2: Use Terminal to Delete All .DS_Store Files in a Folder
Open Terminal (found in /Applications/Utilities) and use the find command. For example, to delete every .DS_Store file on your Desktop:
find ~/Desktop -name .DS_Store -delete
To delete all .DS_Store files on an external drive named MyUSB, first navigate to it with cd /Volumes/MyUSB, then run:
find . -name .DS_Store -delete
This command searches the current folder and all subfolders, then deletes every file with that exact name. It's safe because it only targets .DS_Store files. Be careful with the path—double-check that you're in the right directory before running it.
Method 3: Delete All .DS_Store Files on Your Entire Mac
If you want to clean your whole system, you can run this command from your home folder:
find ~ -name .DS_Store -delete
This will delete every .DS_Store file in your home directory and all subdirectories. It's safe, but you'll lose custom view settings for all your folders. macOS will rebuild them as you open each folder, so the effect is minor.
Preventing .DS_Store Files on Shared Drives
If you regularly share a USB drive between Mac and Windows, you can stop macOS from writing .DS_Store files on that specific drive. This requires a command-line tool called dot_clean or a third-party app, but there's a simpler trick using a file called .metadata_never_index—unfortunately that only affects Spotlight indexing, not .DS_Store creation.
The most reliable method is to use a tool like BlueHarvest or CleanMyDrive, but those are paid apps. A free, built-in alternative is to set the drive to be read-only on your Mac, but that's impractical for normal use.
A practical workaround is to always eject the drive properly and then, before disconnecting, run the Terminal command to delete all .DS_Store files on it. That's not automatic, but it works.
For developers, the best solution is to add .DS_Store to your project's .gitignore file. That prevents it from being committed to version control, even if it exists locally.
Common Misconceptions About .DS_Store
There are a few myths that keep circulating about .DS_Store files:
- They're a virus. No. They're a normal macOS system file. Antivirus software on Windows may flag them because they're hidden and unusual, but they're not malicious.
- They contain personal information. They store folder view settings, not file contents or your browsing history. They might reveal folder names, but that's it.
- Deleting them will break your Mac. No. macOS recreates them automatically. The only side effect is that your folder view preferences reset to default.
- You can disable creation in System Settings. There is no such setting in current macOS versions. The only way is to use third-party tools that run in the background.
Understanding these facts helps you decide when to delete and when to leave them alone.
Frequently Asked Questions
Is .DS_Store a virus?
No. It's a legitimate file created by macOS to store folder view settings. Windows antivirus sometimes flags it as a generic threat because it's hidden and unusual, but it's completely harmless.
Can I delete .DS_Store files from my USB drive?
Yes. You can delete them manually in Finder (press Command+Shift+. to show hidden files) or use Terminal with the command find /Volumes/YourDrive -name .DS_Store -delete. It's safe and they'll come back if you open the drive again on a Mac.
Why do I see .DS_Store on Windows but not on Mac?
On macOS, files starting with a dot are hidden by default. Windows doesn't hide them, so they appear as regular files. That's why you see them on a PC but not on your Mac.
Will deleting .DS_Store files speed up my Mac?
No. They take up negligible space (a few kilobytes each) and don't affect performance. Deleting them is about tidiness, not speed.
How do I stop .DS_Store files from being created on a shared drive?
There's no built-in setting to disable creation. You can use third-party tools like BlueHarvest, or simply delete them before ejecting the drive. For developers, adding .DS_Store to .gitignore prevents them from being committed to code repositories.
Does deleting .DS_Store affect my folder layout?
Yes, for that specific folder. If you delete the .DS_Store in a folder, the next time you open it, macOS will create a new one with default view settings. Your custom icon positions and view mode will reset to the system default.