This commit is contained in:
RandomNinjaAtk
2023-07-19 11:42:07 +00:00
committed by GitHub
parent dd6d63d047
commit a25d05cf20

View File

@@ -1,5 +1,5 @@
#!/usr/bin/with-contenv bash
ScriptVersion="0.1"
ScriptVersion="0.2"
scriptName="Audiobook"
#### Import Settings
@@ -18,12 +18,14 @@ touch "/config/scripts/audiobook.txt"
exec &> >(tee -a "/config/scripts/audiobook.txt")
clean () {
if [ $(find "$1" -type f -regex ".*/.*\.\(m4b\)" | wc -l) -gt 0 ]; then
find "$1" -type f -not -regex ".*/.*\.\(m4b\)" -delete
log "Searching for audiobook (m4b) files..."
if [ $(find "$1" -type f -iname "*.m4b" | wc -l) -gt 0 ]; then
log "M4B files found, removing non m4b files..."
find "$1" -type f -not -iname "*.m4b" -delete
find "$1" -mindepth 2 -type f -exec mv "{}" "$1"/ \;
find "$1" -mindepth 1 -type d -delete
else
echo "ERROR: NO AUDIOBOOK FILES FOUND (M4B)" && exit 1
echo "ERROR: NO audiobook files found (M4B)" && exit 1
fi
}