Skip to content

Commit 28a38cc

Browse files
authored
Create DupeFinders (#30)
1 parent 7c508bd commit 28a38cc

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

radarr_dupefinder.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
directory=${1:-.} # Use provided directory or default to current directory
4+
5+
find "$directory" -type d | while read -r dir; do
6+
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)
7+
if [[ $file_count -gt 1 ]]; then
8+
echo "$dir"
9+
fi
10+
done

sonarr_dupefinder.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
directory=${1:-.} # Use provided directory or default to current directory
4+
5+
find "$directory" -type d | while read -r dir; do
6+
# Extract all matching filenames in the directory
7+
files=($(find "$dir" -maxdepth 1 -type f -regextype posix-extended \
8+
\( -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" \) \
9+
-regex ".*\([0-9]{4}\).*S[0-9]{2}E([0-9]{2}).*" | sed -E 's/.*E([0-9]{2}).*/\1/'))
10+
11+
# Count occurrences of each episode number
12+
declare -A ep_count
13+
for ep in "${files[@]}"; do
14+
((ep_count[$ep]++))
15+
done
16+
17+
# Check if any episode appears more than once
18+
matched=0
19+
for count in "${ep_count[@]}"; do
20+
if [[ $count -gt 1 ]]; then
21+
matched=1
22+
break
23+
fi
24+
done
25+
26+
# Print the directory if it has matching files
27+
if [[ $matched -eq 1 ]]; then
28+
echo "$dir"
29+
fi
30+
31+
# Clear the associative array for the next directory
32+
unset ep_count
33+
done

0 commit comments

Comments
 (0)