I'm trying to work on a script that will crawl my Plex media folder, find any header ".r00" files, extract them in their own directory, and trash the archive zips after it's done. I have two options I've been playing around with. Combined they do what I want, but I would like to have it all in one nice little script.
Option 1:
This script opens the "LinRAR" GUI, makes me navigate to a specific directory, finds and extracts any .r00 file in that directory, and successfully deleted all archive zips.
while true; do if dir=$(zenity --title="LinRAR by dExIT" --file-selection --directory); then if [[ ! -d $dir ]]; then echo "$dir: Wrong Directory" >&2 else ( cd "$dir" && for f in *.r00; do [[ -f $f ]] || continue; rar e "$f" && rm "${f%00}"[0-9][0-9]; done ) fi else echo "$bold Selection cancelled $bold_off" >&2 exit 1 fi zenity --title="What else...?" --question --text="More work to be done?" || break done
Option 2:
This script cd's to my Plex folder, recursively finds any .r00 files, extracts to my /home/user folder, and does not remove the archive zips.
(cd '/home/user/Plex'); while [ "`find . -type f -name '*.r00' | wc -l`" -gt 0 ]; do find -type f -name "*.r00" -exec rar e -- '{}' \; -exec rm -- '{}' \;; done
I would like to have something that takes the first working script, and applies the recursive find to all folders inside of /Plex instead of only letting me navigate to one folder at a time through the "LinRAR" GUI.