parent
4417f6af4f
commit
6d60f5cdae
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Main script logic
|
||||
if [[ $# -eq 0 ]] || [[ ! -d "$1" ]]; then
|
||||
echo "Usage: $0 <Sonarr root folder>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ROOT_FOLDER="$1"
|
||||
|
||||
# Define media file extensions
|
||||
MEDIA_EXTENSIONS="mp4|mkv|avi|mov|wmv|flv|webm|mpeg|mpg|m4v|3gp|3g2|vob|ogv|rm|rmvb|ts|f4v|m2ts|mxf|divx|hevc|asf|swf|drc|amv|yuv|qt|bik|vid|mve|nsv|roq|pmp"
|
||||
|
||||
find "$ROOT_FOLDER" -type d -iname "*\.trickplay" | while read -r TRICKPLAY_FOLDER; do
|
||||
TRICKPLAY_FOLDER="$(realpath "$TRICKPLAY_FOLDER")"
|
||||
MEDIA_BASE_NAME="$(echo "$TRICKPLAY_FOLDER" | basename "$(sed -E 's/.(trickplay)$//')")"
|
||||
PARENT_PATH="$(dirname "$TRICKPLAY_FOLDER")"
|
||||
ESCAPED_MEDIA_BASE_NAME=$(echo "$MEDIA_BASE_NAME" | sed 's/[][\.*^$(){}?+|&-]/\\&/g')
|
||||
|
||||
found_files=$(find "$PARENT_PATH" -type f -regextype posix-extended -regex ".*/${ESCAPED_MEDIA_BASE_NAME}\.($MEDIA_EXTENSIONS)$")
|
||||
|
||||
# Check if any files were found
|
||||
if [[ -z "$found_files" ]]; then
|
||||
echo "$TRICKPLAY_FOLDER"
|
||||
# comment this line if you only want to see orphan trickplay folder without remove them.
|
||||
rm -rf "$TRICKPLAY_FOLDER"
|
||||
fi
|
||||
|
||||
done
|
||||
~
|
||||
Loading…
Reference in new issue