diff --git a/dedup.py b/dedup.py index 6142660..84ad83c 100644 --- a/dedup.py +++ b/dedup.py @@ -163,18 +163,18 @@ def main(): # Calculate scores matrix_score = delibs.matrix_similarity_score(matrix) - if len(sys.argv) > 3: - is_score = sys.argv[3] - else: - is_score = "" - - if matrix_score == 1.0 and is_score != "scores": + if "-scores" in sys.argv: + is_score = True + else: + is_score = False + + if matrix_score == 1.0 and is_score == False: print("❌ Perfect match score, images should be identical - Duplicate Found!") delibs.exit_timer(1) - if matrix_score < 0.3 and is_score != "scores": + if matrix_score < 0.3 and is_score != False: print("👌Not a Duplicate, best guess!") delibs.exit_timer(0) - if is_score == "scores": + if is_score == True: score = delibs.find_duplicate_with_rotation(large_img1, aligned) print(f"Score: {score}") diff --git a/do_dups.inc b/do_dups.inc index 7bb1064..33d1162 100644 --- a/do_dups.inc +++ b/do_dups.inc @@ -61,7 +61,7 @@ for ((i = 0; i < ${#images[@]}; i++)); do case $exit_code in 1) # Duplicate found echo "$path/$outer_image # $inner_image" >> dups.txt - if [ "$2" = "forreal" ]; then + if [ $do_for_real = true ]; then mv "$path/$outer_image" "$path/dups" fi break @@ -90,7 +90,7 @@ for ((i = 0; i < ${#images[@]}; i++)); do ;; 8) # Invalid outer image echo "$path/$outer_image" >> invalid.txt - if [ "$2" = "forreal" ]; then + if [ $do_for_real = true ]; then echo "To remove bad image run: rm $path/$outer_image" fi break diff --git a/get_dups.sh b/get_dups.sh index 1f4bb80..4639f60 100755 --- a/get_dups.sh +++ b/get_dups.sh @@ -14,7 +14,16 @@ if [ ! -d "$path" ]; then exit 1 fi -if [ "$2" = "forreal" ]; then +do_for_real=false +for arg in "$@"; do + if [ "$arg" == "-forreal" ]; then + echo "Found -forreal flag" + do_for_real=true + break + fi +done + +if [ $do_for_real = true ]; then mkdir -p "$path/dups" fi @@ -40,7 +49,7 @@ seconds=$((elapsed % 60)) printf "Total time to dedup everything: %02d:%02d:%02d\n" $hours $minutes $seconds -if [ "$2" != "forreal" ] && [ -f "dups.txt" ]; then +if [ $do_for_real = true ] && [ -f "dups.txt" ]; then echo "Here are your duplicate files:" more dups.txt else