26 lines
653 B
Bash
26 lines
653 B
Bash
|
#!/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
|