File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments