Useful macOS defaults: Desktop Services

com.apple.desktopservices controls how Finder handles .DS_Store files and some desktop behaviours.

.DS_Store files are hidden files that Finder creates in every folder you open. They store view settings: icon positions, sort order, window size, and so on. They are harmless on your own Mac but annoying when they show up on network drives, USB sticks, or in Git repositories.

Stop creating .DS_Store files on network drives

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

This stops Finder from creating .DS_Store files on SMB, AFP, NFS, and WebDAV network shares. Finder still creates them on your local disk.

Stop creating .DS_Store files on USB drives

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

This stops .DS_Store files from appearing on USB flash drives and external disks. Useful if you share drives with Windows or Linux users who would see these files.

Turn them back on

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool false
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool false

Or remove the overrides entirely:

defaults delete com.apple.desktopservices DSDontWriteNetworkStores
defaults delete com.apple.desktopservices DSDontWriteUSBStores

Notes

These settings only stop new .DS_Store files from being created. They do not delete existing ones. To clean up .DS_Store files already on a network share or USB drive:

find /Volumes/MyDrive -name ".DS_Store" -delete

You do not need to restart Finder for these changes to take effect. They apply to new folder visits straight away.


Enjoyed this post?

Well, you could share the post with others, follow me with RSS Feeds and/or send me a comment via email.


Tags

Category:

Year: