Black FridayBlack Friday: Folia Files is 30% off. One payment, yours for good.Until November 29Get the offer

All articles

.DS_Store File on Mac: Stop It on Network Drives and USB Sticks

· 6 min read

A .DS_Store file is a hidden file the Finder writes in a folder to remember how you view it: the view style, the sort order, where the icons sit. It holds none of your data and is safe to delete. On a USB stick or a shared folder that a Windows PC, a NAS or a TV reads, it shows up next to your files, which is why people ask how to get rid of it. You can stop your Mac writing them on network drives with one setting Apple documents, try a second one for USB drives, and delete the ones already there in one go. All three are below, with Terminal and without.

What is a .DS_Store file?

DS stands for Desktop Services, the part of macOS the Finder relies on (its settings are the com.apple.desktopservices ones you'll meet below). When you browse a folder in the Finder, it writes a .DS_Store file in it to keep that folder's view settings: icon view or list, icon positions and size, sort order, window size, background.

Its name starts with a dot, so the Mac hides it. Windows, Linux, a NAS's web page or a smart TV don't treat the dot as "hidden", so they list it. Copy a folder from your Mac to a stick, open the stick on a PC, and you'll often find a .DS_Store in the folders you opened in the Finder.

Is it safe to delete .DS_Store files?

Yes. A .DS_Store file contains no document, photo or setting outside the Finder's view of that folder. Delete it and the folder simply opens with the Finder's default view next time; the Finder writes a new one when you browse it again.

On your Mac's own disk there's no point deleting them: they come back and weigh a few kilobytes. They only bother people on drives and shares that other systems read.

How to stop .DS_Store files on network drives

Apple documents this one in its support article "Adjust SMB browsing behavior in macOS". In Terminal, type:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE

Then log out of your macOS account and log back in. From then on, the Finder no longer writes .DS_Store files on network shares. To undo it, run the same command with FALSE.

Two things to know:

  • it applies to your user account on this Mac only; another Mac browsing the same share still writes its own;
  • it doesn't remove the .DS_Store files already on the share (see below).

How to stop .DS_Store files on USB sticks and external drives

There is a second key for USB drives:

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool TRUE

Apple doesn't document this one, and reports differ on whether recent versions of macOS still honor it. Set it, log out and back in, delete the old .DS_Store files on the stick, then open a few of its folders in the Finder and look again with hidden files shown (⇧⌘.). If a new one appears, your Mac ignores it and the cleanup methods below are what's left.

Neither key changes anything on your Mac's internal disk.

The same settings in Folia Files, without Terminal

Folia Files, a file manager for the Mac, has both settings as switches. Open Settings (⌘,) › Files and Network, section Finder's .DS_Store Files:

  • Don't create .DS_Store files on network volumes;
  • Don't create .DS_Store files on USB disks.

They write the same two keys of the Finder, for your account. Once you change one, Folia shows Takes effect when the Finder restarts. with a Relaunch Finder button. If files still appear, log out and back in, as Apple's article says.

Settings › Files and Network in Folia Files: in Copies, « Don't copy .DS_Store files to another disk »; below it, the section « Finder's .DS_Store Files » with its switches for network volumes and USB disks

This section is in the version of Folia Files from the website; the App Store version doesn't have it. Folia Files itself never writes .DS_Store files: it keeps its own view settings separately.

Copy to a stick without the .DS_Store files

The settings above stop new files. They don't help when you copy a folder from your Mac's disk to a stick or a share: the .DS_Store files already in that folder travel with it.

When the copy is made in Folia Files, they don't. Don't copy .DS_Store files to another disk, in Settings › Files and Network › Copies, is on by default: a copy to a USB stick, an external drive or a network share leaves them out, and a move to another disk doesn't carry them either. This one is in both versions of the app. More about how Folia copies on the page about safe file operations.

Folia's backups and syncs leave out .DS_Store files (and the ._ files below) by default too, as in backing up one folder to an external drive.

How to delete .DS_Store files on a Mac

With Terminal

To delete every .DS_Store file on a drive, type find, the drive's path and the rest:

find /Volumes/USB_STICK -name .DS_Store -delete

Replace /Volumes/USB_STICK with your drive or a folder (drag it from the Finder into the Terminal window to type its path). It removes only files named exactly .DS_Store, in that folder and every folder inside it, and deletes them for good, not to the Trash. On a big network share, it takes a while.

With Folia Files

Folia Files has a ready-made command, Delete .DS_Store Files, that runs that same find on the folder you're looking at:

  1. If it isn't in your list yet, open Settings › Commands, click + and choose Delete .DS_Store Files.
  2. Open the stick or the share in a pane.
  3. Right-click an empty spot in the folder › Commands › Delete .DS_Store Files.
  4. Folia asks Run “Delete .DS_Store Files”? and shows the command line; click Run.

It deletes every .DS_Store in the pane's folder and all its subfolders, for good. Commands are in the website version of Folia Files; the custom commands page of the documentation explains how to write your own, and the terminal page shows the rest of what they do.

To check the result, show hidden files in the pane: ⇧⌘., or right-click an empty spot in the folder › Show Hidden Files. The .DS_Store files appear in the list like any other file.

A folder of photos in Folia Files with hidden files shown: the .DS_Store file at the top of the list, selected

What about the files that start with "._"?

Those are a different thing. On a drive formatted FAT32 or exFAT, the usual format of USB sticks, macOS can't store a file's extended attributes (tags, the quarantine flag of a download and so on) inside the file, so it writes them next to it in a ._ file of the same name. The .DS_Store settings don't stop them.

You can delete them the same way, with -name '._*' in the find command above. The files on that drive then lose those attributes, which a PC or a TV doesn't use anyway. A drive formatted APFS or Mac OS Extended doesn't get ._ files, but Windows can't read it without extra software.