Skip to content

Instantly share code, notes, and snippets.

@lavoiesl
Forked from anonymous/remove_crap.sh
Created May 30, 2012 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lavoiesl/2836192 to your computer and use it in GitHub Desktop.
Save lavoiesl/2836192 to your computer and use it in GitHub Desktop.
Remove temporary and junk files from Windows and OS X
#!/bin/bash
#
# Script to remove temporary and junk files from Windows and OS X
#
### Not set up to run as root. Advised not to do this. ###
#### Variables ####
# Files to remove (Add others, just remember to increment the
# index value between "[]" for each additional file)
# Mac
files[1]='.DS_Store'
files[2]='._*' # Temporary files
# Windows
files[3]='Thumbs.db'
files[4]='thumbs.db'
files[5]='Desktop.ini'
files[6]='desktop.ini'
files[7]='ehthumbs_vista.db'
files[8]='SyncToy*.dat'
files[9]='ignore_my_docs'
# Editors backup
files[10]='*~'
files[11]='*.swp'
# Starting poings (paths) to look for files and folders (Add others, just
# remember to increment the index value between "[]" for
# each additional file)
startpts[1]="`pwd`"
#startpts[2]='/mnt/Videos'
#startpts[3]='/mnt/Music'
#### Start processing ####
echo Removing ${files[@]} from ${startpts[@]}
echo ""
# Combine all filenames in a series of -o -name
options="-name $(echo ${files[@]} | sed 's/ / -o -name /g')"
find ${startpts[@]} $options -print -delete
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment