Created
June 15, 2014 17:15
-
-
Save tmos/0d9fda79cef8859e5af9 to your computer and use it in GitHub Desktop.
A bash script that delete all microsoft-windows-files Thumbs.db in the current folder, and all the sub-directories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
##################################################################################################### | |
# == Thumbs_db_killer == # | |
# This script delete all the Thumbs.db files on the curent folder, and on the sub-folders. # | |
# You can modify the $ennemy variable if you want to bulk-delete an other file (.Sync, of whatever).# | |
# @author : Tom Canac http://tomcanac.com/ # | |
# @version : 1.0 # | |
# @licence : CC-BY # | |
##################################################################################################### | |
recursivity () | |
{ | |
for item in *; do | |
[ -e "$item" ] || continue | |
if [ -d "$item" ]; then # If the current item is a sub-directory : | |
cd "$item" || { echo "You don't have neccesary rights to go through $item" 1>&2; exit 1; }; # Go in it | |
recursivity; | |
cd .. || exit 1; # Go back to the previous directory, and do this again | |
elif [ -f "$item" ] && [ "$ennemy" = "$item" ]; then # If the current item is not a directory, and is named Thumbs.db : | |
rm "$item"; # Delete it | |
i=$((i+1)); # Add one victim to the list | |
fi | |
done | |
} | |
ennemy="Thumbs.db"; | |
i=0; | |
recursivity; | |
echo "$i files named \"$ennemy\" deleted"; | |
exit 0; | |
##################################################################################################### | |
# == Documentation == # | |
# exit-code reference : # | |
# 1 : you don't have the right to go through one of the sub-directory. # | |
# # | |
##################################################################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment