.DS_Store files are hidden files created by macOS in folders to store custom attributes of the folder’s contents. These files maintain details such as icon positions, view options, and metadata associated with the folder’s display settings. These files are designed for a single workstation’s use, but they can clutter shared directories and cause permission errors when moving or deleting files. To prevent the creation of .DS_Store files on network drives, you can follow these simple steps:

  1. Open Terminal: To start, open the Terminal application on your Mac. You can find it in the Applications folder under Utilities, or use Spotlight by pressing Command + Space and typing “Terminal.”

  2. Enter the Command: In the Terminal window, type the following command and hit Enter:

    defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
    
  3. Log Out or Reboot: After entering the command, you will need to either log out of your macOS user account and log back in or simply reboot your workstation. This step is crucial for the changes to take effect.

  4. Verify the Policy: To confirm that the policy to disable .DS_Store files on network drives is in place, you can check the current setting by entering the following command in Terminal:

    defaults read com.apple.desktopservices
    

    If the .DS_Store files are successfully disabled for network drives, you should see “DSDontWriteNetworkStores = 1” displayed in the Terminal.

  5. Removing the Policy (Optional): If you ever need to revert to the default behavior and allow the creation of .DS_Store files on network drives, you can remove the policy by entering the following command in Terminal:

    defaults delete com.apple.desktopservices DSDontWriteNetworkStores
    

By following these steps, you can effectively disable the creation of .DS_Store files on network drives in macOS. This simple adjustment can help improve directory browsing performance and prevent unnecessary clutter and errors in shared storage environments such as NAS.