8

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 to disable creating .Spotlight-V100 and .Trash folders on external drive? and Prevent MacOS from making .* and ._* files!

6
  • Awesome username, by the way.
    – Spiff
    Jul 23, 2010 at 18:57
  • Or on ANY drive, for that matter.
    – NReilingh
    Jul 24, 2010 at 21:21
  • Create them, lock them to make them read-only, then chflags hidden to hide them.
    – Daniel Beck
    Apr 18, 2011 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, 2011 at 21:12
  • @Daniel That's true (hence the word possible); you're right. Thanks for the clarification!
    – squircle
    Apr 19, 2011 at 0:20

2 Answers 2

1

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.

http://hints.macworld.com/article.php?story=20110204124029798

1
  • 2
    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, 2012 at 11:09
0

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 --
loggerTag='umount-wrapper'

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

    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*
  fi
) | 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 {} \;
    else
      echo not msdos, skipping to umount...
    fi

You must log in to answer this question.

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