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