#! /usr/bin/env nix-shell #! nix-shell -i fish -p fish set root_directories /srv/server/pool/multimedia/media/Library/comics \ /srv/server/pool/multimedia/media/Library/manga/manga \ /srv/server/pool/multimedia/media/Library/webtoons set blacklist 'NOBLESSE|Air Gear' for root_dir in $root_directories for dir in (find $root_dir -mindepth 1 -type d) cd $dir fd -q -tfile $blacklist if test $status -eq 0 continue end fd -q -tfile '((\d+|\d+\.\d+)(\.cbz|\.pdf))$' if test $status -eq 1 continue end set max_chapter (find -not -name '*Annual*' -print0 | string match -ar '(\d+|\d+\.\d+)(?=\.cbz|\.pdf)' | sort -h | tail -n 1) set min_chapter (find -not -name '*Vol.*' -not -name '*TPB*' -print0 | string match -ar '(\d+|\d+\.\d+)(?=\.cbz|\.pdf)' | sort -h | head -n 1) set ext (fd . | string match -r '(\.cbz|\.pdf)' | tail -n 1) set base_name (fd . | string match -r '(.*(?