ambevar-dotfiles/.scripts/tc-audio-batch

66 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
if [ -z "$(command -v ffmpeg)" ]; then
echo "ffmpeg required."
exit
fi
if [ ! -f "${0%/*}/titlecase.awk" ]; then
echo "AWK titlecase script required."
exit
fi
if [ ! -f "${0%/*}/tc-audio-transcode" ]; then
echo "tc-audio-transcode script required."
exit
fi
if [ "$1" = "-h" ]; then
cat<<EOF
Usage: ${0##*/} OPTIONS
This will batch process all audio files found in current folders and subfolders with
the tc-audio-transcode script. All arguments are passed to tc-audio-transcode.
For more details see
tc-audio-transcode -h
EOF
exit
fi
IFS="
"
for i in $(find "." \( \
-iname '*.aac' -o \
-iname '*.ape' -o \
-iname '*.flac' -o \
-iname '*.ogg' -o \
-iname '*.mp3' -o \
-iname '*.mpc' -o \
-iname '*.wav' -o \
-iname '*.wv' \) ) ;do
echo "$(tput setf 2)$(tput bold)==>$(tput sgr0) $i"
"${0%/*}/tc-audio-transcode" "$@" "$i"
done
unset IFS
## Alternative.
##
## TODO: Big mystery here. The combination of while, find, and a script
## containing a ffmpeg call seems to mess eveything up.
## This will convert all tracks in current folder and subfolders.
# while read -r i; do
# "${0%/*}/tc-audio-transcode" "$@" "$i"
# done <<EOF
# $(find "." \( \
# -iname '*.mp3' -o \
# -iname '*.flac' -o \
# -iname '*.wv' -o \
# -iname '*.aac' -o \
# -iname '*.wav' -o \
# -iname '*.ape' -o \
# -iname '*.mpc' \) )
# EOF