Most of the time, .ds_store files are harmless and don’t take up much space, but there are still instances where you might want to open or delete them. So, how can you do it?
As a Mac technician, I often see minor bugs in system files that can potentially lead to future issues. The good news is that, with a little bit of instruction, you can keep an eye on your files and folders and keep your system running smoothly.
Table of Contents
Key Takeaways
- .DS_Store files are hidden files on your Mac that contain information regarding the information on how the individual folders in Finder are displayed
- In general, .DS_Store files are safe, and there are a few reasons as to why you may want to delete them.
- .DS_Stores files are not viewable in Finder, but you can use Terminal to find them.
- The folders cannot be edited by the user.
- Certain Network Folders, such as OneDrive, cannot read .DS_Stores files and could potentially create problems.
What Are .ds_store files on Mac?
macOS contains files that are called “dot files”, these are files that have periods in front of them and they are hidden to the average user. One of those files is the .ds_store file.
DS stands for desktop services and these files save and provide information on how the individual folders in Finder are displayed. This includes information on the icon order, the window size, and the window shape. If you are familiar with Windows files, this is extremely similar to the desktop.ini files.
These files are not visible in Finder using the Command-Shift-. chortcut as of macOS Mojave, and are only able to be opened or deleted using Terminal. These files cannot be edited by the user.
In general, .ds_store files are harmless files that do not take up a lot of storage space. There are very few circumstances in which you would like to delete them, such as if you would like to reset your display settings for a certain folder, you notice that Finder is behaving in an odd way when you are opening a specific file, or you are about to transfer a file to another system. Then you may want to delete the files to allow your Mac to reset the files or avoid another system having trouble with reading the file.
Additionally, .ds_store files can unfortunately be used by hackers to gain access to your personal information. So, especially for developers that use public repositories to share folders, you may want to delete .ds_store files to keep yourself safe! Deleting .ds_store files is safe for your Mac, you will not create problems with Finder or lose any data.
How to Open .DS_Store Files on Mac
Unfortunately, .DS_Store files are unable to be seen using the typical ‘unhide files’ Terminal commands or keyboard strokes (this change was made with macOS Mojave). However, if you would like to see the contents of the file, you can view them in Terminal. It will look something like this:
Note that there is much more information in the file, but this is the basic idea. You can see that it has information on icon size, files, position, text size, etc.
The commands are as follows:
cd /YourFilePath
This will allow you to navigate the Folder that you would like to see the .DS_Store file for.
cat .DS_Store
This will allow you to view the contents of the file.
How to Delete .DS_Store Files on Mac
There are two different ways to delete .DS_Stores files. You can manually delete them from a specific folder, you can delete ALL .DS_Stores files. We will discuss how to do each!
Manually Deleting .DS_Stores Files for a Specific Folder
Once again using Terminal, the commands will look like this:
The commands will be as follows:
cd /YourFilePath will bring you to the folder that you are looking to delete the .DS_Store file for.
find . -name ‘.DS_Store’ -type f -delete will delete the .DS_Store file.
Delete ALL .DS_Store Files
Additionally, to delete all the .DS_Store files, it will look like the following:
The command is as follows:
Sudo find / -name “.DS_Store” -depth -exec rm {} \;
This will delete all the files. You will be prompted to enter your password, enter it (know that it will not show anything on your Terminal screen) and press enter.
How to Prevent Creation of .DS_Store Files in Network Folders
Lastly, sometimes, you may want to shut off the creation of .DS_Store files for folders that are located on network drives. This could be helpful if the Network Folders will be accessed from non-Mac devices.
Network folders, such as OneDrive, cannot read .DS_Store files and it can periodically create problems. Turning it off will help stop those problems before they happen.
Turning off the .DS_Store files for Network folders will look like this:
The command is:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
If you ever want to turn the .DS_Stores files back on for the Network Folders, it will look like this:
The command is:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Final Words
In general, .DS_Stores files are very easy to view and work with if you are familiar with Terminal and using the commands.
Even if you are not, simply following this article step by step will help you to understand everything you need to know regarding viewing and deleting .DS_Store files. These files, a typically safe and they are acceptable to delete, you do not have to worry about losing any data, only simply losing any saved views of your folders.