Skip to content

How to delete all .DS_Store files on MacOS

homepage-banner

Introduction

.DS_Store files are invisible files that contain information about the folder’s view settings in MacOS. These files can be useful, but they can also clutter up your folders and cause issues with version control systems. If you want to delete all of the .DS_Store files on your MacOS device, you can do so using the Terminal app. In this blog post, we’ll show you how to batch delete these files.

Using Terminal to Batch Delete .DS_Store Files

(1) Open Terminal by searching for it in Spotlight or by navigating to Applications > Utilities > Terminal. (2) Navigate to the directory where you want to delete the .DS_Store files. For example, if you want to delete all .DS_Store files in your Documents folder, type the following command:

cd ~/Documents

(3) Once you’re in the correct directory, run the following command to delete all .DS_Store files in that directory and its subdirectories:

find /Users/$(whoami) -name ".DS_Store" -depth -exec rm {} \;

This command uses the find command to search for all files named “.DS_Store” in the current directory (represented by the .). The -depth option ensures that it searches the subdirectories before the parent directory, and the -exec option runs the rm command on each file that is found.

(4) After running the command, you should see a list of all the files that were deleted.

Leave your message