Last active
February 6, 2025 20:22
-
-
Save Mageas/5a20163d6aecfe3919d09fd6f01beaf1 to your computer and use it in GitHub Desktop.
Remove empty jellyfin Shows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PARENT_DIRS=("Shows" "Movies") | |
prefix="[$(date '+%Y-%m-%d %H:%M')]" | |
script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
if [[ -z "${script_path}" || "${script_path}" == "/" || ! -d "${script_path}" ]]; then | |
echo "${prefix} ERROR: Invalid script path: ${script_path}" | |
exit 1 | |
fi | |
cd "${script_path}" | |
check_forbidden_files() { | |
find "${1}" -type f \ | |
! -iname "*.jpg" \ | |
! -iname "*.png" \ | |
! -iname "*.svg" \ | |
! -iname "*.nfo" \ | |
| wc -l | |
} | |
for ROOT_DIR in "${PARENT_DIRS[@]}"; do | |
[[ ! -d "${ROOT_DIR}" ]] && continue | |
find "${ROOT_DIR}" -mindepth 1 -maxdepth 1 -type d | while read -r current_dir; do | |
if [[ $(check_forbidden_files "${current_dir}") -eq 0 ]]; then | |
echo "${prefix} Removing : ${current_dir}" | |
rm -rf "${script_path}/${current_dir}" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add crontab
Open crontab :
Crontab command (execute every 5 minutes) :