In the macOS, there are some files that are created automatically in different directories. Although they may seem useless, they play an important role in the proper functioning of the operating system, and so should not be deleted. One such file is a .DS_Store file. In this article, we’ll explain what it is and how to remove it, along with the reasons why you might need to do it.

What is .DS_Store?

While it appears to be a useless addition to a folder, a .DS_Store file (the “DS” stands for “Desktop Services”) is important in helping Mac work out how to display folders when you open them. 

The Finder creates the file whenever a .zip file is created and contains information about how a folder will be opened, such as icon positions, window size and shape, and the window’s position when last opened on the desktop. You might also find .DS_Store files in archives that you’ve received from other Mac users.

The files, as they sit in a folder on your Mac, don’t cause any harm, which is good because the only way to stop them from being created is to quit using the Finder, and that’s something none of us want to consider. 

why-delete-ds-store-files

Why would you need to delete .DS_Store files?

So why would you want to get rid of a file that doesn’t cause any harm and takes up very little space in a folder? Here are a few reasons:

  1. You want to reset your display settings.
  2. The Finder is behaving oddly when opening a folder. As with any computer file, it’s possible for .DS_Store files to become corrupted. Things such as the inability to see or sort icons, change view options, or a folder that closes within a second of being opened are a sure sign of a .DS_Store gone bad.
  3. You’re transferring files between your Mac and another system. When moving files from your computer over to a Windows or Linux system, a .DS_Store file can cause unexpected problems. They’re alien to PCs and can raise suspicions from users unfamiliar with macOS.
how-delete-ds-store-files

How to delete a .DS_Store file 

Before we show you how it’s done, let us, first of all, reassure you that deleting a .DS_Store file is perfectly safe. No harm will come to a folder. 

You should also know that as soon as the settings are changed, the Finder will create a new .DS_Store file that you’ll probably want to delete at some point. Basically, it’s a never-ending battle — you versus .DS_Store. 

Deleting .DS_Store files: The easy way

Using a tool like CleanMyMac lets you delete .DS_Store files easily and in bulk without having to go down the manual route of entering Terminal commands. It’s also a sure-fire way of making sure every trace of .DS_Store is removed from your folders.

.DS_Store falls under the category of System Junk on CleanMyMac, which is essentially what it is when you no longer need a file. Removing files couldn’t be simpler:

  1. Get your free CleanMyMac trial.
  2. Open the app.
  3. Click Cleanup from the sidebar menu.
  4. Hit Scan and wait for CleanMyMac to do its thing.
  5. Click Clean for no more .DS_Store dictating how your folders should look.

And you’re all done. There won’t be a .DS_Store file to be found… Until your Mac creates a new one.

Deleting .DS_Store files manually

If you want to go down the manual route and delete .DS_Store files individually, you can do this using the Terminal: 

  1. Go to Applications > Utilities > Terminal.
  2. Locate the folder or directory that you want to remove the .DS_Store file from.
  3. Type cd into the Terminal followed by your folder path, so it looks something like this: cd /Users/username/nameoffolder
  4. Press Return.
  5. Type find . -name ‘.DS_Store’ -type f -delete
  6. Press Return again. 

.DS_Store files in the selected folder will now disappear.

How to prevent security breaches through .DS_Store files

Did you know that .DS_Store files can pose severe security risks? It is because they store custom metadata/attributes of other files and directories, so if this sensitive information is exposed, cybercriminals can obtain access to private data.

To prevent security breaches, you can disable the automatic creation of these files. Here’s how to do it: 

  1. Once again, open Terminal.
  2. Enter this command followed by Return:
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true
  3. Restart your Mac. 

If you need to enable the creation of .DS_Store files in the future, use this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores false

.DS_Store files are an important part of macOS, helping your Mac work the way you’re used to. Helpful as they are, sometimes, you need to remove these files, and as you now know, you can do it either manually or automatically. If you choose the manual way, make sure to closely follow the steps above and double-check the commands you run in Terminal.