sodcalculator

10 Tech How-To

What Is .DS_Store and How to Remove It on macOS

Guide 10-50849 · Updated · Step by step

If you’ve ever looked inside a folder on a Mac or received a zip file from a macOS user, you’ve likely seen a file named .DS_Store. It’s a hidden system file that macOS creates automatically in every folder you open with Finder. This article explains what .DS_Store is, why it exists, whether you should delete it, and the safest ways to remove it from your Mac or prevent it from appearing in shared archives.

What Exactly Is .DS_Store?

.DS_Store stands for Desktop Services Store. It’s a hidden file created by the macOS Finder to store custom view settings for each folder: icon positions, window size, sort order, background image, and whether the folder is displayed as icons, list, columns, or gallery. The name is a legacy of the older Mac OS X (10.0–10.3) where the file was called .DS_Store and was used by the Finder’s Desktop Services framework.

Every time you open a folder in Finder, macOS checks if a .DS_Store file exists. If it doesn’t, the system creates one and writes the current view preferences into it. This is why you’ll find .DS_Store files scattered across your drives, even on folders you’ve never explicitly customized. The file is hidden by default in Finder, so most users never notice it until they use the command line or receive a zip file that includes it.

Why Does macOS Create .DS_Store Files?

The purpose of .DS_Store is to preserve your personal view settings for each folder. Without it, every folder would reset to a default view every time you reopened it, which would be annoying if you prefer a specific icon size or sort order. The file is written by the Finder process and is not part of the actual folder contents—it’s metadata stored as a separate file.

Because .DS_Store is specific to each user account, it can cause issues when you copy folders to another Mac or share them via zip. The new user’s Finder may read the old .DS_Store and apply settings that don’t match their preferences, or the file may trigger warnings about hidden files. That’s why many developers and designers add .DS_Store to their .gitignore files to prevent it from being committed to version control repositories.

Is .DS_Store Safe to Delete?

Yes, .DS_Store files are completely safe to delete. They are not system-critical, and macOS will recreate them the next time you open the folder in Finder. Deleting a .DS_Store file only removes the saved view preferences for that folder—nothing else is affected. Your files, folder structure, and data remain untouched.

However, you should never delete the .DS_Store file that exists at the root of your startup disk (usually named .DS_Store in the top-level directory). That file stores the desktop view settings, and while deleting it won’t break anything, it will reset your desktop icons arrangement. It’s still safe, but you might lose your custom layout.

How to Remove .DS_Store Files from Your Mac

There are several ways to remove .DS_Store files, depending on whether you want to delete a single file, clean up a specific folder, or remove all of them at once. Here are the most common methods:

Method 1: Delete a Single .DS_Store File

  1. Open Terminal (found in Applications > Utilities).
  2. Type the following command and press Enter, replacing /path/to/folder with the actual folder path:
    rm /path/to/folder/.DS_Store
  3. If you get a permission error, you may need to use sudo before the command, but be cautious—only use sudo when you’re certain the path is correct.

Method 2: Remove All .DS_Store Files in a Specific Folder (Recursively)

  1. Open Terminal.
  2. Run this command to delete every .DS_Store inside the current folder and all subfolders:
    find . -name ".DS_Store" -delete
  3. Replace the . with a full path if you want to target a different directory.

Method 3: Clean Your Entire System

  1. Open Terminal.
  2. Run this command to delete all .DS_Store files on your primary drive (requires admin password):
    sudo find / -name ".DS_Store" -delete 2>/dev/null
  3. This will take a while and may show warnings about files you don’t have permission to delete—that’s normal. The 2>/dev/null suppresses error messages.

Method 4: Use Finder’s Hidden Files Toggle

  1. Press Command + Shift + . (period) in any Finder window to toggle hidden files visibility.
  2. Navigate to the folder containing .DS_Store, right-click the file, and choose Move to Trash.
  3. Empty the Trash to permanently delete it.

How to Prevent .DS_Store from Being Created

You can’t stop macOS from creating .DS_Store files entirely—it’s a core Finder feature. But you can disable them on network volumes and external drives, which is where they often cause problems. To do that, run the following command in Terminal:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

Then restart Finder by holding Option and right-clicking the Finder icon in the Dock, then choosing Relaunch. This prevents .DS_Store files from being created on network shares (like SMB or AFP servers). For external drives, you’d need to use a similar command, but Apple doesn’t provide an official switch—you’d have to rely on third-party tools or manually delete them.

Removing .DS_Store from ZIP Files and Git Repositories

When you zip a folder on macOS, the archive often includes .DS_Store files. To avoid this, you can use the command line to create a zip that excludes them:

zip -r archive.zip folder/ -x "*.DS_Store"

If you’re using Git, add the following line to your .gitignore file:

.DS_Store

This tells Git to ignore any file named .DS_Store, so it won’t be committed to the repository. If you’ve already committed .DS_Store files, you can remove them from the repository with:

git rm --cached .DS_Store

Common Misconceptions About .DS_Store

One common misconception is that .DS_Store files are viruses or malware. They are not—they’re plain metadata files created by Apple. However, because they are hidden and appear in unexpected places, some antivirus programs or users mistake them for threats. Another misconception is that deleting .DS_Store will speed up your Mac. In practice, these files are tiny (usually a few kilobytes) and have negligible impact on performance. The only real reason to delete them is to clean up shared archives or to fix view-settings glitches.

Frequently Asked Questions

Can I delete .DS_Store from my USB drive?

Yes, you can safely delete .DS_Store files from any external drive. They are not needed for the drive to function, and macOS will recreate them if you open the drive in Finder again. If you want to prevent them from being created on the USB drive, you’d need to use the network-stores trick only if it’s a network volume—for local USB drives, there’s no built-in way to disable .DS_Store creation.

Why do I see .DS_Store when I unzip a file on Windows?

When a Mac user zips a folder, the archive may include hidden .DS_Store files. Windows doesn’t hide files that start with a dot by default, so you see them as normal files. They are harmless—you can delete them without affecting the other files in the archive.

Is .DS_Store a security risk?

No, .DS_Store files contain only view preferences and folder layout information. They do not contain personal data, passwords, or file contents. However, in rare cases, they might reveal folder names or structure if the folder itself is sensitive, but that’s not a significant risk.

Will deleting .DS_Store affect my folder view settings?

Yes, deleting a .DS_Store file will reset the view settings for that specific folder to the default. Your files remain intact, but you’ll lose any custom icon arrangement, sort order, or window size you set for that folder. You can easily reapply your preferences after reopening the folder.

How do I show hidden files in Finder to see .DS_Store?

Press Command + Shift + . (period) in any Finder window. This toggles the visibility of all hidden files, including .DS_Store. Press the same shortcut again to hide them.

Can I stop .DS_Store from being created on my Mac entirely?

No, there’s no supported way to disable .DS_Store creation on your local startup disk. It’s a core part of Finder. You can only disable it for network volumes using the defaults command mentioned earlier. For local folders, the best you can do is periodically delete them or exclude them from backups and archives.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →