If you’ve used a Mac for long enough, you know that when you create folders on macOS, the system automatically creates .DS_Store — or Desktop Services Store — files for each folder. These files are useful for keeping track of metadata and folder settings, like folder view options, sort options, and icon size and position.
And because this system file contains a dot in front of it (commonly known as a dot-file), you usually don’t see this file, as it’s automatically hidden in the Finder, even if you manually enable hidden file viewing in the Finder. However, if you share or view a folder that was created on a Mac on another operating system or via file sharing, you will.
SEE: Check out these tips on how to secure the work data on your Mac.
This is where the problem can happen: When you create a folder on a network drive from within macOS and the Finder, these .DS_Store files will be created automatically. If you or your server admin become frustrated by the seemingly endless creation of these files, there is a quick and easy way to turn off the creation of .DS_Store files.
Stop .DS_Store on network stores
To stop having the Finder automatically create these files with network stores:
1. Open Terminal app — located in Applications > Utilities — and enter the following command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
2. Press return.
3. After the command is executed, reboot your Mac, and you’ll be good to go — no more .DS_Store files gunking up your network shares (Figure A).
Figure A
If you need to set certain folders a particular way and want to re-enable the creation of these files, the fix is just as simple.
To re-enable the .DS_Store file creation on network stores:
1. Open Terminal, and enter the command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores false
2. Reboot your system once the command is executed.
Note: The change is considered a per-user modification, so if you’re in a corporate environment with multiple Apple users, this command must be performed from each user’s account when logged on with their profile. This may be scripted out and run by your IT department as a logon script or as part of ongoing maintenance routine tasks through Apple Remote Desktop or other third-party management suites.
On network drives, you can easily remove the .DS_Store files that were created previously by just deleting them from the network drive.
Stop .DS_Store on removable drives
There is a hidden command in Terminal that can even stop .DS_Store files from being created on removable drives, such as USB drives, thumb drives and SD cards.
To stop .DS_Store files from being created on removable drives and media
1. Open the Terminal — located in Applications > Utilities — and enter the following command (Figure B):
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
Figure B
2. Reboot your system once it’s executed.
If you find that you want the functionality back for removable media, you can go back to the default by typing the following command in Terminal and rebooting once done:
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool false
This customization makes it easy to ensure you don’t pollute network shares and removable media with these files when likely you won’t take advantage of the features Finder stores in these files. This will also go a long way to making Windows and Linux users stay sane when macOS users share files and folders with them.