When our company hired a graphic designer, she introduced the first Mac computer to our network. Since then, we noticed an increase in annoying “poop files”, as I started calling them. Every time she'd edit a file on the network, her Mac would create a copy of it, calling it ._filename. Then, during a backup, I realised I was backing up a ton of these poop files. So, I created a script to remove them all for me. I renamed the poop files “Rabbit Droppings”, as I figured calling my script “poop” wouldn't attract many users.
With Linux, backup files get a tilde (~) at the end. To me, this is a security risk, because it results in password.php becoming a web-readable password.php~. If $password = “supersecret”;, it's not all that secret anymore if that file gets accidentally uploaded to a public server.
This script removes Mac ._ files, Linux *~ files, and Windows thumbnail caches.
V1.0 - Initial Release
V1.1 - Added Desktop.ini
#!/bin/bash echo echo Rabbit Droppings 1.1 echo By Robbie Ferguson, www.category5.tv echo Use this script at your own risk. if [ -z "$1" ]; then echo echo This script clears out Windows, Mac and Linux temp files echo \(I call them rabbit droppings\) from the current echo or specified folder. echo echo Because you have not specified a folder, I\'m clearing the echo current folder, recursively of any rabbit droppings. echo echo Usage: $0 folder echo Where folder is the folder or mountpoint you\'d like to clean up. echo echo Example: $0 \/home \<- will clear out the temp files echo from your \/home folder, recursively fi echo if [ $1 ]; then echo Detecting rabbit droppings recursive to $1... else echo Detecting rabbit droppings recursive to your current folder... fi echo #output the list find 2>/dev/null $1 -iname "*~" -o -iname "._*" -o -iname ".DS_Store" -o -iname "Thumbs.db" -o -iname "Desktop.ini" read -p "Okay to delete the above rabbit droppings? (Y/N) " if [ "$REPLY" = "y" ] ; then APPROVE="1" fi if [ "$REPLY" = "Y" ] ; then APPROVE="1" fi echo if [ "$APPROVE" = "1" ]; then #remove the files find 2>/dev/null $1 -iname "._*" -exec rm -rf {} \; find 2>/dev/null $1 -iname "*~" -exec rm -rf {} \; find 2>/dev/null $1 -iname ".DS_Store" -exec rm -rf {} \; find 2>/dev/null $1 -iname "Thumbs.db" -exec rm -rf {} \; find 2>/dev/null $1 -iname "Desktop.ini" -exec rm -rf {} \; else echo Cancelled. fi