Remove DS_Store files from Mac

What Is a DS_Store File and How to Remove It

by Elsie Otachi

A .Ds_Store (Desktop Services Store) file is an information file hidden on your Mac’s operating system that the macOS creates automatically whenever you browse a folder through the Finder app.

The file is created for each folder and contains information that controls how the OS will open the folder with the associated system configuration metadata. The data includes background images, size or orientation of the icons, how to display folders when you open them, etc. 

Are DS_Store Files Harmful?

You can find DS_store files in archives received from other Mac users but don’t cause any harm while they’re in a folder. 

DS_Store files are usually hidden from view, but you can enable the hidden files setting and view the files. 

  1. To enable hidden files, select Go > Computer and then select Macintosh HD to expand the section.
  1. Select Command + Shift + . (the period key). The grayed-out files you see are typically the hidden files in your Mac. 

However, if you upload a DS_Store file along with other files to your Mac, there’s a chance they can be misused to get information like file attributes or metadata about the files on your Mac. It could potentially allow hackers to act maliciously and view your private files. 

How to Delete a DS_Store File

Here are a few reasons why you’d want to delete a DS_Store file, even if it doesn’t take up much space in a folder or cause any harm:

When Finder acts up each time you try to open a folder. 

  • Corrupted DS_Store files can make it hard for you to change view options and see or sort file icons within the folder.  When a folder closes immediately, it’s a sign of a corrupted DS_Store file. 
  • To reset your display preferences by deleting a DS_Store file. You will lose custom Finder view settings for the particular folder, but you can always change the folder’s view options or settings.
  • If you’re transferring files between computers, like from your Mac to another system, you may encounter some unexpected problems caused by DS_Store files. 

Some quick ways to resolve any problems you face with DS_Store files include:

  • Open DS_Store files with suitable applications on non-macOS systems like Windows. Some tools you can use to open DS_Store files in Windows include WinRARAdobe Acrobat, and Free File Viewer.
  • Ensuring your DS_Store file isn’t corrupted or infected with a virus or malware. You can run a malware scan using the best antivirus options for Mac and check for any potential threats.

You don’t lose any data when deleting a DS_Store file. But, once the folder preferences are changed, Finder will create a new DS_Store to store custom view settings. 

We’ll show you how to delete a DS_Store file: 

  • For a specific folder 
  • For multiple folders in your Mac through the Terminal application

How to Delete a DS_Store File for a Specific Folder

Use these steps to delete a DS_Store file from a specific folder.

  1. Select Go > Utilities > Terminal.

Note: If you’re not signed in as an administrator, you may be asked to enter your name and password to access the Terminal app and use the commands needed to delete DS_Store files.

  1. Locate the folder and change the directory to the folder containing the DS_Store file you want to delete. For example, if the folder is on the desktop, use the cd desktop command and press Enter
  1. Type find . –name ‘.DS_Store’ –type f –delete to delete all DS_Store files in the current directory and press Enter

Note: Make sure you type out the command exactly as intended otherwise you may delete other important files on your Mac.

  1. Select OK. The .DS_Store files in the folder you selected will be deleted.

Note: Terminal will send a message only if the command you entered didn’t work.

How to Delete a DS_Store File for Multiple Folders

If you want to delete all DS_Store files from your Mac, follow these steps.

  1. Select Go > Utilities > Terminal
  1. Enter this command in the Terminal window: sudo find / -name “.DS_Store” -depth -exec rm {} \; and press Enter.
  1. Enter your password, if prompted. The DS_Store files will be deleted from all the folders.

Note: The app will return a message only if the command you entered didn’t work.

How to Prevent Automatic Creation of DS_Store Files

If there are random folders on your server, hackers may get access to the DS_Store files, view attributes or metadata about the file, and act maliciously.

The best way to resolve this problem and prevent security breaches through DS_Store files is to disable the automatic creation of DS_Store files. Here’s how.

  1. Select Go > Utilities > Terminal.
  1. Type defaults write DSDontWriteNetworkStores true and press Enter. If you ever want to reverse this command, use the same command but change true to false.
  2. Restart your Mac. 

    How to Automatically Delete .DS_Store Files Periodically 

    If you don’t want to keep deleting DS_Store files the manual way, you can use a UNIX command to automatically remove the files at regular intervals. Here’s how.

    1. Select Go > Utilities > Terminal.
    1. Type or paste this command in Terminal: sudo crontab -e and press the Return key.
    2. If prompted, enter your administrator password
    3. In the vim editor, press i on your keyboard once. Then type or paste this command: 30 10 * * * root find / -name “.DS_Store” -depth -exec rm {} \;

Note: The crontab entry is in the following format: <Minute> <Hour> <DayOfMonth> <Month> <DayOfWeek> <User Command>. In our example, the system is set to automatically run the command at 10.30 AM every day. You can use different values to configure the command for a different time and the command will run whether your Mac is on or in Sleep mode.

  1. Press the Esc key on your keyboard once and then press Shift + Z + Z simultaneously to save the crontab entry. 

Remove DS_Store Files from Your Mac

Most Mac users aren’t aware that DS_Store files exist. These invisible files live in the system folders of your Mac, and you can remove them or disable the creation of the files using the steps outlined in this guide. 

Leave a Reply

your credientials will not be public


  • Apple
  • Macbook
  • SSD
  • Linux


  • Hints 64