diff --git a/scripts/transcode_flac.sh b/scripts/transcode_flac.sh new file mode 100755 index 0000000..161499c --- /dev/null +++ b/scripts/transcode_flac.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +# evaluate options through given arguments +file_suffix='wav' +map= +while [[ $# > 0 ]]; do + case $1 in + -t | --type) file_suffix=$2; shift 2;; + -map ) map='-map 0:0'; shift;; + * ) break ;; # Anything else stops command line processing. + esac +done + +# ensure existence of destination folder +dir="$(pwd)" +dest=${dir%/*}/${dir##*/}_flac +if [[ !(-d $dest) ]]; then + mkdir "$dest" +fi + +for file in ./*.$file_suffix; do + echo "ffmpeg -i '$file' -c:a flac $map '$dest/${file%$file_suffix}flac'"; + ffmpeg -i "$file" -c:a flac $map "$dest/${file%$file_suffix}flac"; +done