HOW TO - remove ._ files (AppleDouble) files from a file server

Steps to remove ._ files

What are dotfiles?

When writing to a non-Mac file system, Macs create a separate file for each file and folder that contains metadata about the file or folder called "AppleDouble" files.  These have the same name as the files and folders in a directory, but are prepended with "._".  MacOS hides these files, but you will see them on Windows, Linux, or in a Mac Terminal window.  They don't do any real harm other than taking up space and making directories look VERY full.  They do also take up (a little bit of) space, so getting rid of them can clean up both the look at storage space on a shared drive.

With MacOS 10.5 and later, Apple included a utility called "dot_clean" which will merge the metadata kept in these AppleDouble files with the original file, and then delete the AppleDouble file.  For the man page (manual page, or help file) for dot_clean, see https://ss64.com/mac/dot_clean.html or type man dot_clean in a MacOS terminal window.

Instructions for running dot_clean:

  1. Press [Shift]-[Command]-[U] to open the "Utilities" folder

  2. Double-click on the Terminal icon

  3. Type cd /volumes

  4. Type ls.  
    • You should see "Macintosh HD" and any other mounted shares. 
    • IMPORTANT:  If you do NOT see the name of the share you want to clean, then you'll need to mount the correct share
      • Click anywhere on the desktop
      • Press [Command]-[K] to bring up the "Connect to Server" dialog box and connect to the share you want to clean.
      • Go back to the terminal window you opened earlier and repeat type ls to be sure you see the share there now.
  5. Assuming that the share you want to clean is mounted, we'll run the command:  dot_clean -m -n -v /volumes/[sharename]
    • For explanations of the options selected, see below

Important flags that modify how the script operates: 

There are some things you may want to know:

  1. -f tells the script to run in the specified directory only.  WIthout this, the script will run in the specified directory and all subdirectories.
  2. -m forces the script to delete the ._ files after merging their contents with the data file
  3. -n tells the script to delete any ._ file that does not have an associated data file (without this, it ignores orphaned ._ files)
  4. -v prints verbose output, so you can see what is done.  You can exlude this if you want
  5. Folder names with spaces: If a subfolder name has spaces, you'll want to put quotes around the entire volume name

Examples: 

  1. dot_clean -f -m -n -v /volumes/sharename
    • Runs in the specific directory only (no subdirectories)
    • Deletes the ._ files after merging them with their associated data file
    • Deletes orphaned ._ files
    • Uses verbose output
  2. dot_clean -m -n "/volumes/sharename/folder 1"
    • Runs in a directory with a space (note the quotes around the name) and all subdirectories
    • Deletes the ._ files after merging them with their associated data file
    • Deletes orphaned ._ files
    • Uses minimal output (no verbose flag)


Keywords:
resource fork mac dotclean dot_clean dotfiles dotunderscore underscore dot 
Doc ID:
135369
Owned by:
SU Jay G. in School of Chemical Sciences
UIUC
Created:
2024-02-09
Updated:
2024-02-09
Sites:
University of Illinois School of Chemical Sciences