From 317c856ae57d0858d0c7b1198c581831d2a7cb31 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:34:55 -0600 Subject: [PATCH 1/3] Create radarr_dupefinder.sh --- radarr_dupefinder.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 radarr_dupefinder.sh diff --git a/radarr_dupefinder.sh b/radarr_dupefinder.sh new file mode 100644 index 0000000..0348ddd --- /dev/null +++ b/radarr_dupefinder.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +directory=${1:-.} # Use provided directory or default to current directory + +find "$directory" -type d | while read -r dir; do + file_count=$(find "$dir" -maxdepth 1 -type f \( -iname "*.mp4" -o -iname "*.mkv" -o -iname "*.avi" -o -iname "*.mov" -o -iname "*.wmv" -o -iname "*.flv" -o -iname "*.webm" -o -iname "*.mpg" -o -iname "*.mpeg" \) | wc -l) + if [[ $file_count -gt 1 ]]; then + echo "$dir" + fi +done From 337b4b7eadabcecaa4779ec8856c04a6b5d544b0 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:36:29 -0600 Subject: [PATCH 2/3] Create sonarr_dupefinder.sh --- sonarr_dupefinder.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sonarr_dupefinder.sh diff --git a/sonarr_dupefinder.sh b/sonarr_dupefinder.sh new file mode 100644 index 0000000..70d7cb2 --- /dev/null +++ b/sonarr_dupefinder.sh @@ -0,0 +1,34 @@ +file_count=$(find "$dir" -maxdepth 1 -type f \( -iname "*.mp4" -o -iname "*.mkv" -o -iname "*.avi" -o -iname "*.mov" -o -iname "*.wmv" -o -iname "*.flv" -o -iname "*.webm" -o -iname "*.mpg" -o -iname "*.mpeg" \) | wc -l) +#!/bin/bash + +directory=${1:-.} # Use provided directory or default to current directory + +find "$directory" -type d | while read -r dir; do + # Extract all matching filenames in the directory +files=($(find "$dir" -maxdepth 1 -type f -regextype posix-extended \ + \( -iname "*.mp4" -o -iname "*.mkv" -o -iname "*.avi" -o -iname "*.mov" -o -iname "*.wmv" -o -iname "*.flv" -o -iname "*.webm" -o -iname "*.mpg" -o -iname "*.mpeg" \) \ + -regex ".*\([0-9]{4}\).*S[0-9]{2}E([0-9]{2}).*" | sed -E 's/.*E([0-9]{2}).*/\1/')) + + # Count occurrences of each episode number + declare -A ep_count + for ep in "${files[@]}"; do + ((ep_count[$ep]++)) + done + + # Check if any episode appears more than once + matched=0 + for count in "${ep_count[@]}"; do + if [[ $count -gt 1 ]]; then + matched=1 + break + fi + done + + # Print the directory if it has matching files + if [[ $matched -eq 1 ]]; then + echo "$dir" + fi + + # Clear the associative array for the next directory + unset ep_count +done From 7e0406f1538a2c0c46f1955f7b663cc1433a5357 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:37:14 -0600 Subject: [PATCH 3/3] fixup! --- sonarr_dupefinder.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/sonarr_dupefinder.sh b/sonarr_dupefinder.sh index 70d7cb2..4c9d4b9 100644 --- a/sonarr_dupefinder.sh +++ b/sonarr_dupefinder.sh @@ -1,4 +1,3 @@ -file_count=$(find "$dir" -maxdepth 1 -type f \( -iname "*.mp4" -o -iname "*.mkv" -o -iname "*.avi" -o -iname "*.mov" -o -iname "*.wmv" -o -iname "*.flv" -o -iname "*.webm" -o -iname "*.mpg" -o -iname "*.mpeg" \) | wc -l) #!/bin/bash directory=${1:-.} # Use provided directory or default to current directory