brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dot_clean -m removes the ._ files a Mac leaves on USB sticks and shares

Files
~/tips/tip-macos-dot-clean-appledouble

dot_clean -m /Volumes/USBSTICK

Cleans up the ._ metadata files macOS leaves on USB sticks and shared folders.

Plug a USB stick that has been used on a Mac into a TV or a Windows laptop and you often see a twin for every file, starting with ._. Those are AppleDouble files, where macOS keeps Mac metadata on disks that can’t store it in the file itself. Apple has a tool for exactly this mess, and it’s called dot_clean.

Point it at a folder or a mounted volume. By default it merges each ._ file back into its real file and then removes it. With -m it always deletes them:

dot_clean -m /Volumes/USBSTICK

That’s what I’d run right before ejecting a stick that’s headed for a car stereo, a TV or a friend on Windows. It works recursively through every folder, -f keeps it to the top folder only, and -v prints what it does. You can use it on a share too, for example a folder on a NAS that both a Mac and Linux machines use.

There’s also -n, which only deletes the orphans: ._ files whose real file is gone. That’s the gentle option when the folder is also used on a Mac and you just want the leftovers cleaned up.

My caveat: those files aren’t junk to macOS. They hold extended attributes, the Mac metadata that had nowhere else to go on that disk. On a disk that only Macs use, I’d leave them alone, or use plain dot_clean without -m so the metadata is merged instead of thrown away. Copying more files from a Mac to the stick can bring new ones, so run it as the last step.

Further reading: dot_clean man page (SS64)

More Files tips sha256sum -c --ignore-missing SHA256SUMS xxhsum -H64 backup.tar > backup.xxh unzip -j archive.zip -d out/ Files > More > Select > pick files > More > Compress ls -lhS /var/log All Files tips (15) All topics

Link