Remove .DS_Store and ._.DS_Store under Windows

Article shows you how to remove all occurrences of files .DS_Store and ._.DS_Store in the current directory and all sub-directories under Windows.

What is this article about?

When you move from a Mac OSX onto Windows, the file system will contain two files under every directory labeled “.DS_Store” and “._.DS_Store”. These files are not useful especially if you’re trying to commit code under a Git source control. It can sometime get very annoying and to eliminate this “noise” from your day to day development, you may want to remove these artifacts from your Windows system. This article will walk you through the simple steps of removing those files.

Performing the steps

Windows “find” utility works differently than Linux “find”. I highly recommend you use Cygwin (free). Cygwin provides you with Linux utilities under Windows. (Examples includes ls, rm, xargs, etc.) Once you have Cygwin, you can navigate to the base directory of you choice:

Example: To navigate to the c:\projects, you will run:

cd /cygdrive/c/projects

Once you’re in the folder/directory of your choosing, you can then run the following two commands.

# First let's find all occurrences of both ".DS_Store" and "._.DS_Store" (recursive)     
find . -type f \( -name ".DS_Store" -o -name "._.DS_Store" \) -print0
# After we have ensured that the results are good then let's rerun and pipe it to the rm (remove) command via xargs
find . -type f \( -name ".DS_Store" -o -name "._.DS_Store" \) -print0 | xargs -0 rm 

This should now remove all occurrences of those two files from a Windows directory (recursive)


Buy Me A Coffee

Today’s Quote

The roof of Peace rests upon the walls of understanding.
- Thiru Valluvar ( His Work )