Find and Delete All .DS_Store Files with One Simple Command

Spread the love

If you are a Mac OS X user, you will probably be familiar with the “.DS_Store” file that the system automatically creates when you open a folder. What the “.DS_Store” file does is store custom attributes of the folder, such as the position of icons or the choice of a background image, so that the next time you open the same folder it will remain in the same state as the previous session.

The “.DS_Store” file is hidden by default, and most of the time it doesn’t cause any trouble – that is until you need to zip the folder and send it to your friends (using another operating system) or upload your development folder to the server. You will find that the folder contains many unsightly “DS_Store” files that you don’t want to share with you friends.

If you are looking for a way to quickly remove all instances of “.DS_Store” file in a folder, here is a command that you can use:

Note: the following command will work in Linux as well.

1. Open a terminal in your Mac OS X.

2. Enter the following command:

find /path/to-folder \( -name '.DS_Store' \) -delete

Replace the “/path/to/folder” with the actual filepath of the folder, for example “/var/www/html.”

What the above command does is use the find command to search a particular folder (recursively) for files with a name that includes “.DS_Store” and delete them when found.

That’s it. You can now easily remove all instances of “.DS_Store” files before you share the folder with others.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Damien Oh

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Comments are closed