Back to articles

Disable .DS_Store on Network/USB Drives

If you're tired of macOS cluttering up every folder with hidden .DS_Store files, you can easily disable them for non-local drives using a few Terminal commands.

For Network Drives:

bash
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE

For External Media (USB sticks, etc.):

bash
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool TRUE

How to Apply the Changes: For these settings to take effect, you’ll need to either restart your Mac or relaunch Finder (you can do this via the "Force Quit" menu).

How to Undo: If you ever need to revert to the default behavior, simply run the same commands again but replace TRUE with FALSE at the end.

Cleaning Up Existing Files via PowerShell:

powershell
"Z:\","Y:\" | % { if(Test-Path $_){ Write-Host "Cleaning $_..." -F Cyan; Get-ChildItem -Path $_ -Include ".DS_Store" -Recurse -Force -EA SilentlyContinue | Remove-Item -Force -Verbose } }

Replace Z or Y with the actual letter assigned to your network map or USB drive (e.g., "D:\","E:\")

macosbashpowershell