A .DS_Store file is a hidden folder created automatically by macOS to store display settings for that folder
Every time you open a folder on a Mac, the operating system creates a file called .DS_Store (short for "Desktop Services Store") inside that folder. This file remembers things like the window size, icon positions, background color, and view settings for that specific folder. The next time you open the folder, macOS reads this file to restore those exact settings.
The file is hidden by default, which is why you probably have never seen it. macOS hides files that start with a dot to keep your folders looking clean. But the file is there, working quietly in the background on nearly every folder you have ever opened on your Mac.
These files are completely harmless and normal. They do not contain personal information, do not affect how your Mac runs, and do not need to be deleted. However, they can cause problems in specific situations — mainly when you move folders between a Mac and a Windows computer, or when you use cloud storage or version control systems.
Key Takeaways
- .DS_Store files are created automatically by macOS in every folder you open and store display settings like window size and icon positions.
- These files are hidden by default and are harmless — they do not contain personal data or affect your Mac's performance.
- Problems arise when .DS_Store files are shared with Windows users or synced to cloud storage, where they appear as unwanted clutter.
- You can prevent new .DS_Store files from being created on external drives and network locations using Terminal commands.
- Deleting existing .DS_Store files is safe and will not harm your Mac, though macOS will recreate them the next time you open those folders.
Why .DS_Store files appear on external drives and shared folders
When you plug in an external hard drive or USB stick and browse its folders on your Mac, macOS creates .DS_Store files on that drive just as it does on your internal drive. The same thing happens when you access a network folder or shared drive. This is automatic and unavoidable under normal circumstances.
The problem occurs when someone using a Windows computer opens that same external drive or folder. Windows does not understand .DS_Store files and displays them as strange, unnamed files with odd icons. If you are collaborating with Windows users or sharing drives between computers, these files clutter the view and confuse people who do not know what they are.
The issue also appears in cloud storage services like Dropbox, Google Drive, or OneDrive. When macOS creates .DS_Store files in a synced folder, those files get uploaded to the cloud and then downloaded to other computers and devices. This wastes storage space and creates unnecessary clutter in shared folders.
How to prevent .DS_Store files on external drives
You can tell macOS to stop creating .DS_Store files on external drives and network locations. This requires using Terminal, which is the command-line tool built into every Mac. If you have never used Terminal before, the process is straightforward — you copy a command, paste it, and press Enter.
Open Terminal (search for it in Spotlight by pressing Command + Space, type "Terminal", and press Enter). Then copy and paste this command exactly as written:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
Press Enter and wait for the command to finish. You will not see a confirmation message — the prompt will simply return. This command tells macOS to skip creating .DS_Store files on external drives, USB sticks, and network locations. It does not affect .DS_Store files on your main hard drive, which is fine because those files stay on your Mac and do not cause problems.
If you ever want to reverse this change, open Terminal again and paste this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool false
Deleting existing .DS_Store files safely
If .DS_Store files already exist on an external drive or in a shared folder, you can delete them. This is completely safe — deleting these files will not harm your Mac or affect any of your actual documents and photos. The only consequence is that folder view settings will reset to defaults the next time you open those folders.
The easiest way to delete them is to use Terminal. Open Terminal and paste this command, replacing /path/to/folder with the actual location of the folder:
find /path/to/folder -name ".DS_Store" -type f -delete
For example, if your external drive is named "BackupDrive" and you want to clean out all .DS_Store files on it, the command would be:
find /Volumes/BackupDrive -name ".DS_Store" -type f -delete
This command searches through every subfolder and deletes every .DS_Store file it finds. It may take a minute or two if there are many folders. When it finishes, the prompt returns with no message.
Alternatively, if you prefer not to use Terminal, you can show hidden files in Finder and delete .DS_Store files manually. Press Command + Shift + Period (the period key) to toggle hidden files on and off in any Finder window. This reveals all the dot files, and you can then select and delete .DS_Store files by hand.
When .DS_Store files matter and when they do not
On your main Mac hard drive, .DS_Store files are completely invisible and harmless. They take up only a small amount of space (usually a few kilobytes per folder) and do not slow down your Mac. You should never need to think about them or delete them from your internal drive.
The files only become a concern in three situations: when you share an external drive with Windows users, when you sync a folder to cloud storage that other people access, or when you use version control systems like Git (which are designed to track code and do not need .DS_Store files cluttering the repository). In those cases, preventing new files from being created is the best solution.
If you have already deleted .DS_Store files from an external drive or shared folder, macOS will recreate them the next time you open those folders on your Mac. This is normal and expected. If you want to prevent this, use the Terminal command described above to disable .DS_Store creation on external drives permanently.
Understanding .DS_Store in version control and Git
If you work with code or use Git (a system for tracking changes to files), .DS_Store files can become annoying. Every time you open a folder in a Git project, macOS creates a .DS_Store file, and Git sees it as a change that needs to be tracked. This pollutes your project history with files that have nothing to do with your actual code.
Developers solve this by adding .DS_Store to a .gitignore file, which tells Git to ignore these files and not track them. If you are working on a shared coding project, the .gitignore file usually already includes .DS_Store, so you do not need to do anything. If you are starting your own project, you can add the line .DS_Store to your .gitignore file to prevent these files from being tracked.
Frequently Asked Questions
Can I safely delete all .DS_Store files from my Mac?
Yes, deleting .DS_Store files is completely safe. They will not harm your Mac or your documents. The only effect is that folder view settings will reset to defaults the next time you open those folders. macOS will recreate the files automatically as you use your Mac.
Do .DS_Store files slow down my Mac or use a lot of storage?
No. Each .DS_Store file is typically just a few kilobytes and has no impact on your Mac's performance. Even if you have thousands of them, they use negligible storage space and do not affect how fast your Mac runs.
Why does my Windows computer show strange files when I open a Mac drive?
Those are .DS_Store files created by macOS. Windows does not recognize them and displays them as unnamed files. They are harmless, but you can prevent new ones from being created by using the Terminal command to disable .DS_Store creation on external drives.
What happens if I disable .DS_Store creation on external drives?
macOS will stop creating new .DS_Store files on external drives and network locations. Folder view settings will not be saved for those drives, so they will reset to defaults each time you open them. Your internal Mac drive is unaffected and will continue creating .DS_Store files normally.
Do .DS_Store files contain personal information?
No. .DS_Store files only store display settings like window size, icon positions, and view preferences. They do not contain passwords, browsing history, personal documents, or any sensitive data.