From c3cb18999e51122488805af20112b6b5f3f17dca Mon Sep 17 00:00:00 2001 From: esche Date: Sat, 8 Jul 2023 00:06:12 +0200 Subject: [PATCH] small bugfix and code cleanup --- to_opus.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/to_opus.sh b/to_opus.sh index c418a0f..876d5e4 100644 --- a/to_opus.sh +++ b/to_opus.sh @@ -18,6 +18,7 @@ print_help() { printf "Help: not implemented yet" } +delete="false" while getopts 'e:dh' flag; do case "${flag}" in e) extension+=("$OPTARG");; @@ -28,10 +29,10 @@ while getopts 'e:dh' flag; do esac done +echo "$delete" + # write array into string extension="${extension[*]}" -# remove leading space -extension="${extension##+([[:space:]])}" # change separator extension=${extension// /|} @@ -60,10 +61,10 @@ for file in **/*.@($extension); do is_video=$(ffprobe -v error -select_streams V -show_entries stream=codec_type "$file") if [[ ${#channels[@]} -gt 1 || -n "$is_video" ]]; then ffmpeg -i "$file" -map 0 -map -0:d -map -0:t -c copy -c:a libopus $bitrate_settings-v info -hide_banner "${file%.*}.mkv" && - if [[ delete="true" ]]; then rm "$file"; fi + if [[ "$delete"=true ]]; then rm "$file"; fi else ffmpeg -i "$file" $bitrate_settings-v info -hide_banner "${file%.*}.opus" && - if [[ delete="true" ]]; then rm "$file"; fi + if [[ "$delete"=true ]]; then rm "$file"; fi fi done