X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Ffiles%2Fwhack_dupes.sh;h=ac20b3d9b847f8ee38cb8c81a56b7a26894b8897;hb=3f11b26ebf3d7bf9fb4fb00813034eda0076f8c0;hp=aa90cb6cd5f41f63ae193d034194a7725ba44e13;hpb=2952ccf47b80174880141a7ecfa122089f349b8d;p=feisty_meow.git diff --git a/scripts/files/whack_dupes.sh b/scripts/files/whack_dupes.sh index aa90cb6c..ac20b3d9 100644 --- a/scripts/files/whack_dupes.sh +++ b/scripts/files/whack_dupes.sh @@ -2,31 +2,29 @@ # whacks the files in the current directory which are duplicates of the # files in the directory passed as a parameter. -# if there is a second parameter, then it is used as the "current directory". +# if there is a second parameter, then it is used as the "current directory" +# and it will be the target of any deletions. exemplar_dir="$1"; shift whack_dir="$1"; shift # make sure they gave us a good directory to start with. if [ -z "$exemplar_dir" ]; then - echo "whack_dupes" - echo "-----------" - echo "" - echo "This program needs at least one directory parameter. The files in the" - echo "current directory will be removed if a file in the specified directory" - echo "already exists. So... the current directory is the less important one" - echo "and is presumed to have duplicates AND the directory given as parameter" - echo "is considered important and has the best versions of the files." + echo "$(basename $0 .sh): This program needs at least one directory parameter." + echo "The files in the current directory will be removed if a file in the specified directory" + echo "already exists. So... the current directory is the less important one and is presumed" + echo "to have duplicates AND the directory given as parameter is considered important and has" + echo "the best versions of the files." echo "If there is an optional second parameter, then that is used as the" echo "\"current\" directory where we start from; it will be the less important" echo "directory and will have its entries cleaned if they're duplicates." - exit 42; + exit 1 fi # check to make sure they gave us a good directory. if [ ! -z "$whack_dir" -a ! -d "$whack_dir" ]; then echo "the directory $whack_dir does not exist." - exit 3 + exit 1 fi # test the tasty remote location with the better contents. @@ -34,7 +32,7 @@ pushd "$exemplar_dir" &>/dev/null if [ $? -ne 0 ]; then # an error getting to this directory means its no good for us. echo "the directory $exemplar_dir is inaccessible." - exit 2 + exit 1 fi the_good_place="$(pwd)" popd &>/dev/null @@ -46,12 +44,12 @@ fi current_dir="$(pwd)" -echo "currdir=$current_dir gooddir=$the_good_place" +#echo "currdir=$current_dir gooddir=$the_good_place" if [ "$current_dir" == "$the_good_place" ]; then # this is not good; they're the same location. echo "the request would whack all the files in the current directory; ignoring." - exit 4 + exit 1 fi # do the real work now...