Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hidden files and folders like .fseventsd, .Spotlight-V100, .TemporaryItems, and .Trashes are getting dumped in my flash drive every time I plug it into my Mac...

How do I keep it from doing this?

Related to How disable mac snow leopard creating .Spotlight-V100 and .Trash folders in USB Flash Drivers? and Prevent MacOS from making .* and ._* files!

share|improve this question
Awesome username, by the way. – Spiff Jul 23 '10 at 18:57
Or on ANY drive, for that matter. – NReilingh Jul 24 '10 at 21:21
Create them, lock them to make them read-only, then chflags hidden to hide them. – Daniel Beck Apr 18 '11 at 20:00
@squircle I disagree. ._ files are the only hidden files regularly created that aren't mentioned in this topic. – Daniel Beck Apr 18 '11 at 21:12
@Daniel That's true (hence the word possible); you're right. Thanks for the clarification! – squircle Apr 19 '11 at 0:20

Macworld has an article describing a way to delete the hidden Mac dot files. The hints suggest modifying the default unmount script. Use care because the script could delete other hidden files like .bashrc that you may want.

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Ivo Flipse Jul 15 '12 at 11:09

I like the general concept in the Macworld article referenced by @Dave, but I don't want to nuke intentionally placed hidden files or folders (especially .git or .svn) and I want to clean up non-msdos filesystems as well as dos.

Note that this will cause scripted deletion/destruction of your files, so I recommend you only do this if you pretty much comprehend what this script does and you're OK with potential mayhem.

I took their suggested script and changed it as shown below. As they said there, before editing make sure to sudo mv /sbin/umount /sbin/umount-orig (so this script can invoke the original umount). After editing, sudo chmod 555 /sbin/umount and sudo chown root:wheel /sbin/umount.

#!/bin/sh --

  if [ "$@" ]; then
    for i in "$@"; do
      echo $i

    echo "cleaning mounted filesystem before running umount-orig..."
    rm -rf "$1"/._*
    rm -rf "$1"/.Trash*
    rm -rf "$1"/.Spotlight*
    rm -rf "$1"/.DS_Store
    rm -rf "$1"/.fseven*
) | logger -st $loggerTag

/sbin/umount-orig "$@"

For reference (in case the link disappears), the original said to use the following to clean up, but depending on filesystem type:

    fstype=`diskutil info "$1" | sed 's/ //g' | grep '^Type:' | cut -d':' -f2`

    echo "fstype is ${fstype}"

    if [ "$fstype" = "msdos" ]; then
      echo cleaning msdos filesystem...
      find "$1" -depth -name '.[^.]*' -print -exec /bin/rm -fr {} \;
      echo not msdos, skipping to umount...
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .