You are not logged in.
Basically I call the script, point it to a source directory ($1) and a target directory (tdirectory) and then:
find "$1" -depth -iname '*.ape' | while read file ; do
directory=$(dirname "$file")
oldfilename=$(basename "$file")
newfilename=$(echo "$oldfilename" | tr 'A-Z' 'a-z')
newfilename=${newfilename/%.ape/.wav}
newfile=$tdirectory/$newfilename
mp3filename=${newfilename/%.wav/.mp3}
mp3file=$tdirectory/$mp3filename
echo "Converting $file to WAV format"
ffmpeg -i "$file" "$newfile"
echo "Converting $newfile to MP3 format"
lame ${lame_opts} "$newfile" "$mp3file"
done
exit 0
If I comment out the ffmpeg and lame parts, it works. Otherwise the first ape file will be processed successfully but the second file does not have the source directory in its name and a file not found error is triggered. For example, the first will processed will be "ape/file1.ape" and the second will be "/file2.ape". What am I doing wrong?
Offline
Well, i don't see you giving the tdirectory variable a value. If you supply it as the second parameter when you call the script, you could try adding
tdirectory=$2
somewhere before using it
Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!
Offline
Thanks klixon. tdirectory=$2 is indeed in the script but not shown. It is irrelevant to my problem as it only supplies the path to the directory for the final output file whereas my problem is with the path to the source file which somehow gets changed when the second file is to be processed.
Offline
Still no idea why the script doesn't work with the ffmpeg and lame commands inserted. But this one works:
if [ -z $1 ];then
echo "Give source directory";
exit 0;
fi
if [ -z $2 ];then
echo "Give source file type";
exit 0;
fi
#first cd to source directory
cd $1
# convert to wav using ffmpeg
for file in *.$2; do ffmpeg -i "$file" "${file%.*}".wav; done
echo "source files have been converted to wav"
echo "doing mp3 conversion now"
for file in *.wav; do lame --preset extreme --quiet "$file" "${file%.*}".mp3; done
echo "all done"
exit 0
Thanks to azleifel here
Now to figure out how to transfer tag info, especially for ape files.
Last edited by stryder (2009-11-26 10:28:54)
Offline