diff --git a/clean_orphaned_trickplays.sh b/clean_orphaned_trickplays.sh new file mode 100644 index 0000000..c285a07 --- /dev/null +++ b/clean_orphaned_trickplays.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +# Main script logic +if [[ $# -eq 0 ]] || [[ ! -d "$1" ]]; then + echo "Usage: $0 " + 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 +~ \ No newline at end of file diff --git a/fix_font_mime.sh b/fix_font_mime_all.sh similarity index 100% rename from fix_font_mime.sh rename to fix_font_mime_all.sh