Manage .DS_Store files on Mac

If We are using a Mac, we can see that whenever we create any folder in macOs, the system automatically creates a DS_Store files for each folder. and as these files contains dot at in-front of the file, so usually we can’t see these file which is hidden by nature.

What is .DS_Store File?

DS_Store stands for Desktop Services Store. .DS_store file is a hidden file on a Mac that stores custom attributes of its containing folder such as folder view options, icon positions and other visual informations.
The Mac Finder automatically creates these .DS_Store files for each folder we create on a Mac. The file follows the folder wherever it goes, including when archived and moved to any repository etc.

Is .DS_Store file safe?

A DS_Store files don’t cause any problem in a folder on the Mac, But they can be misused to obtain information about our computer if we upload them along with other files.
Usually we don’t see .DS_Store files because they are automatically hidden in the Finder. However, We might see them if We share or view a folder that was created on a Mac on another operating system or via file sharing. 

How to Make .DS_Store Files visible?

The Command ls -lA is used to show the invisible files in Mac.

The A flag of the ls command will include invisible files like .DS_Store in the listing.

How to delete the .DS_Store Files in Mac?

The Command rm .DS_Store will delete these files.

To ignore .DS_Store files globally in a Git repository, we can:

  1. Create or edit a .gitignore file in the root of your Git repository.
  2. Add .DS_Store to the .gitignore file.
  3. Save and close the file.

Disable the creation of .DS_Store file in Network devices.

To stop creation of .DS_Store files in Network Stores. Run the below Command

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Note: Once command is executed, reboot the Mac

Disable the creation of .DS_Store file in Removal devices.

To stop creation of .DS_Store files in Removal Devices. Run the below Command

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Note: Once command is executed, reboot the Mac.

If We want the functionality back for removable devices, we 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

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top