Story Details

  • Automating the cleaning of macOS-specific ( ._ and .DS_Store) files on Eject

    Posted: 2025-02-09 02:00:06

    This blog post details how to automatically remove macOS-specific files (.DS_Store and ._*) from external drives upon ejection. The author uses a combination of AppleScript and a LaunchAgent to trigger a cleanup script whenever a volume is ejected. The script leverages dot_clean to efficiently delete these often-annoying hidden files, preventing their proliferation on non-macOS systems. This automated approach replaces the need for manual cleanup and ensures a cleaner experience when sharing drives between different operating systems.

    Summary of Comments ( 18 )
    https://news.ycombinator.com/item?id=42987848

    Commenters on Hacker News largely appreciated the simplicity and directness of the provided AppleScript solution for removing macOS-specific files from external drives upon ejection. Some highlighted the potential for data loss if used carelessly, especially with networked drives or if the script were modified to delete different files. Others offered alternative solutions, including using dot_clean, incorporating the script into a Hazel rule, or employing a shell script with find. The discussion also touched upon the annoyance factor of these files on other operating systems and the historical reasons for their existence, with some suggesting that their prevalence has diminished. A few commenters mentioned more robust solutions for syncing and backing up, which would obviate the need for such a script altogether.