Clean macOS Dot Files With Ease Using a Service

If you use a Mac and Windows together, you’re likely to end up with a bunch of hidden ".DS_STORE" "__MACOSX" and other "._" files all over your drives and folders. You won't see them when using your macOS but as soon as you plug your drive into a Windoze or Linux machine there they are, messing your neatly organized files.

You can easily search and destroy them all before unpluging the drive or right before zipping a folder by using a simple Service script right from your macOS GUI. Let's create that service then!

Create the DotClean Service

  1. Open Automator
  2. When Automator starts a new script it will ask you what kind of script. Choose Service
  3. Find the "Run Shell Script" action on the left pane and drag it to the right pane
  4. At the top where says "Service receives selected" choose folders
  5. In the next box, where says "in" choose
  6. In the action box in "Shell" type /bin/bash
  7. In the next box, the "Pass input" choose as arguments.
  8. Inside the script box write the following:

    find "$*" -name "._*" -exec rm -v {} \;
    find "$*" -name ".DS_Store" -exec rm -v {} \;
    find "$*" -name "__MACOSX" -exec rm -rv {} \;

  9. Now click the menu File > Save, or CMD + S to save the service.
  10. Give it a name, such as Clean Dots, or Clean Dot Files (in fact anything you like).

That's it! Now every time you right click a folder, you'll have this option in your Services submenu. Just select the option and all dot files from this folder and from its subfolders will be wiped out.

Download and Install

If you do not want to mess with Automator, here is the service workflow file:
  1. To install it first extract the .workflow script within the zip file.
  2. Then open a Finder window, press CMD + SHIFT + G and type ~/Library/Services.
  3. Now move the .workflow file into that folder.
That's it!


Now every time you right click a folder you'll have the Clean Dots option. Just select it to wipe out those pesky dot files recursively, from the folder you've selected and from all it's subfolders as well.

When you use the menu option you'll see a little cog wheel spinning on your MenuBar, up there close to the clock. When the cog wheel disappears the folder would be clean of dot files.
{{ message }}

{{ 'Comments are closed.' | trans }}