m4a2mp3
Code:
#!/bin/sh
#
# m4a to wav to mp3
for i in *.m4a; do
faad "$i"
x=`echo "$i"|sed -e 's/.m4a/.wav/'`
y=`echo "$i"|sed -e 's/.m4a/.mp3/'`
lame -h -b 192 "$x" "$y"
# Comment the line below if you want to keep the .wav files
rm "$x"
done
Obviously, you need faad2 and lame installed.
While I'm at it...
m4a2wav
Code:
#!/bin/sh
#
# m4a to wav
for i in *.m4a; do
faad "$i"
done
You need faad for that one
mp32wav
Code:
#!/bin/sh
#
# mp3 to wav
#
# This script will encode ALL .mp3's in the working
# directory to .wav format. No need to pass any arguments.
# Especially usefull for preparing a group of files
# to be burned to an audio CD.
for i in *.mp3; do
echo "$i"
tgt=$(echo "$i" | sed -e "s/mp3/wav/")
mpg123 -b 10000 -s -r 44100 "$i" | sox -t raw -r 44100 -s -w -c2 - "$tgt"
done
You need mpg123 and sox for that one
wma2mp3
Code:
#!/bin/bash
#
#############################################################
# Move the conversion process into a function that can
# be called.
# The "&&" makes it so each step must be successful before
# the next step will be done.
#############################################################
function wma2mp3 () {
if [ ! -f "$1" ]; then
echo "File $1 not found!"
else
mplayer -ao pcm -aofile "${1%%.[Ww][Mm][Aa]}.wav" "$1" &&
lame -h -b 192 "${1%%.[Ww][Mm][Aa]}.wav" "${1%%.[Ww][Mm][Aa]}.mp3" &&
rm -f "${1%%.[Ww][Mm][Aa]}.wav" ||
echo "There was a problem with the conversion process!"
fi
}
#############################################################
# Not enough information to compute
#############################################################
if [ $# -lt 1 ]; then
echo
echo "Usage: wma2mp3 myfile.wma"
echo " wma2mp3 myfile.wma myfile2.wma myfile3.wma"
echo ' wma2mp3 "my file with spaces in the name.wma"'
echo ' wma2mp3 "file with spaces 1.wma" "file with spaces 2.wma"'
echo ' wma2mp3 "*.wma"'
echo " wma2mp3 /directory/containing/wma/files"
echo
exit
fi
#############################################################
# Directory was passed so convert all wma files in directory
#############################################################
if [ $# -eq 1 -a -d "$1" ]; then
for file in $1/*.[Ww][Mm][Aa]
do
wma2mp3 "$file"
done
exit
fi
#############################################################
# One or more wma files were passed, convert them
#############################################################
for file in $*
do
wma2mp3 "$file"
done
exit
EDIT: That one is all screwed up. I fixed it on the wiki tho...
You need mplayer and lame for that one. Notice above that you HAVE to name that script "wma2mp3"....
That opens up some options using one or more in tandem.... I still need to clean up some of that. I got burned out on this awhile ago. They all work tho. Just the usage needs to be tweaked...
Actually, If I'm not mistaken, faad2 comes with an XMMS plugin that works flawlessly with .m4a's... I think it's faad2... Been awhile...