Getting Rid of ._ and .DS_Store Files

Getting Rid of ._ and .DS_Store Files

You may be a Windows user who received a bunch of folders from a work colleague who is using a Mac. Or you may be frequently sharing files between a Mac and a Windows computer. Or you may be copying files from your Mac to USB sticks. Whatever the use case, you must have encountered the mystical and annoying ._ files.

What exactly are these files? How do you get rid of them? These are the questions that I hope to answer in this blog post.

AppleDouble Files

Under Macintosh file systems such as HFS (Hierarchical File System), HFS+ (also known as MacOS Extended) or APFS (Apple File System) files are composed of two pieces called forks. These two pieces are called data fork and resource fork. The data fork is akin to what we call a file in Windows. It contains the actual data like text in a word document. The resource fork contains the meta data and extended attributes. What appears as a single file under the Macintosh file system splits into two files under certain other file systems such as FAT. The file with the same name as the original contains the data fork. The file that starts with ._original file name contains the resource fork. This is the origin of mystical “AppleDouble” files.

Desktop Services Store Files

The default file manager in the Apple macOS operating system, Finder creates Desktop Services Store files (abbreviated as .DS_Store) in every folder. The .DS_Store files keep metadata about its containing folder. These include things like positions of icons and information about background images. When a folder is transferred from a Mac to a PC or a USB stick, these macOS hidden files starts to show up under all directories.

Windows del Command to the Rescue

Windows del command that deletes one or more files can be used to wipe out ._ and .DS_Store files. This command can be run from Windows Command Prompt. The syntax shown below will not work under Windows PowerShell.

The command del /s /f /q /a:h ._* should get rid of all AppleDouble files.

The command del /s /f /q /a:h .DS_Store should get rid of desktop services store files.

The /f flag forces deletion of read-only files. The /s flag makes deletion recursive through current sub directory and all of its sub directories. The /q which stand for quiet mode prevents prompt for delete confirmation. Finally, the /a:h attribute makes deletion of hidden files possible.