From 0c7adfadcb6c262d8355641ba5d03ceafcd92c81 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Wed, 26 Aug 2026 12:48:50 -0700 Subject: [PATCH] pull-plex, automatically remove empty directories. --- bashrc.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bashrc.sh b/bashrc.sh index 3fdd919..9358e7b 100755 --- a/bashrc.sh +++ b/bashrc.sh @@ -396,9 +396,16 @@ function pull-plex { echo -e "\n`date` - Combining videos split into chunks." cd "$dest" ls | while read dir; do - echo -e "\n Checking '$dir'" + echo -e "\n\n`date` - Checking '$dir'" + ls -lh "$dir"/*.mkv 2>/dev/null || + ls -lh "$dir"/* 2>/dev/null || + { + echo " Directory is empty, removing." + rmdir -v "$dir" + echo " Skipping to next directory." + continue + } cd "$dir" - ls -lh # Unsure why -e and -f don't work here. Spaces in filenames? Globs? if [[ `ls *.chunk0 2>/dev/null` ]]; then final="$dir.mkv" @@ -409,6 +416,7 @@ function pull-plex { mv -v *.chunk* ~/TRASH/ fi + echo "`date` - Done." cd .. done }