POSIX_Scripts/bach

24 lines
550 B
Bash
Executable File

#!/bin/sh -e
if [ $# -le 1 ]
then
printf "This script will take two variables and convert all audio files of the first format to the second, using ffmpeg. \n"
elif [ $# -ge 3 ]
then
printf "You've entered too many variables. We only need two... did you not check the help? \n"
else
i=`ls | grep $1 | wc -l`
p=1
mkdir $2
while [ $p -le $i ]
do
x=`ls | sed "$p!d"`
y=`printf "$x" | sed "s/$1/$2/"`
yes | ffmpeg -i "$x" "$y"
mv "$y" $2/
p=$(( $p + 1 ))
done
fi