Quote:
|
Originally Posted by scottro
What about sed '/s[.]wav/.mp3/'
You should always be a bit more specific with error messages
|
Hi thanks for your comments - you are correct I omitted the trailing slash, in the post.
I've always found (unfortunately) the more text you enter the quicker people lose interest - see my other posts there are only a few, with no responses
Anyway the backgroud to my project.....
I have all my CD's ripped to disk as wav files. I want to write an app which looks through the (input) wav directory structure, then through the destination mp3 structure, where it finds files on the input and not the output, it uses LAME to create an mp3 version in an identical directory structure to the wav original.
For example:
The source file would be - /data/wav/Visage/The Damned Don't Cry/04-Mind Of A Toy.wav
The destination would be - /data/mp3/Visage/The Damned Don't Cry/04-Mind Of A Toy.mp3
When the input root is set to - /data/wav
and the output root is set to - /data/mp3
The following is my script so far (please excuse all the remarking etc.):
#! /bin/sh
# var init
input_dir_root=
output_dir_root=
bitrate=
razza=0
ray=
while getopts i:o:b: options; do
case "$options" in
i) input_dir_root="$OPTARG" ;;
o) output_dir_root="$OPTARG" ;;
b) bitrate="$OPTARG" ;;
esac
done
shift $(( $OPTIND - 1 ))
echo ================================================== ==========
echo Rays WAV to MP3 LAME wrapper
echo ------------------------------------------------------------
echo Input Root = $input_dir_root
echo Output Root = $output_dir_root
echo Bitrate = $bitrate
echo Tempfile = $input_dir_root/razza.txt
echo ------------------------------------------------------------
echo Files to convert:
### Delete files (infile etc.)
rm /data/infile.txt
rm /data/convfile.txt
### list files that exist in source root.
find $input_dir_root -name *.wav | xargs -0 echo >> /data/infile.txt
#Read /data/infile check destination for file existence, then create list of files to be converted.
#cat /data/infile.txt |while read LINE
#do echo "${LINE}"
#Replace .wav extension with .mp3
#read razza
#sed -e 's/[.]wav/.mp3/' > /data/convfile.txt
#${infile_line}
#[[ -f ${line} ]] && echo "File exists" || echo "File does not exists"
#done
while read LINE
do
echo $LINE
#read razza
#echo -e $LINE/ray2 >> /data/ray
#sed "s/[.]wav/.mp3/" >$ray <$LINE
export ray=`$LINE |sed 's/[.]wav/.mp3/'`
echo -e $ray >> /data/convfile.txt
done </data/infile.txt
echo ================================================== ==========
The contents of /data/infile.txt are:
/data/wav/ABC/Absolutely/03-All Of My Heart.wav
/data/wav/ABC/Absolutely/04-Tears Are Not Enough.wav
/data/wav/ABC/Absolutely/01-Poison Arrow.wav
/data/wav/ABC/Absolutely/02-The Look Of Love.wav
/data/wav/Visage/The Damned Don't Cry/04-Mind Of A Toy.wav
/data/wav/Visage/The Damned Don't Cry/03-Fade To Grey.wav
/data/wav/Visage/The Damned Don't Cry/02-Tar.wav
/data/wav/Visage/The Damned Don't Cry/01-Visage.wav
/data/wav/Visage/Visage/04-Tar.wav
/data/wav/Visage/Visage/02-Blocks On Blocks.wav
/data/wav/Visage/Visage/01-Visage.wav
/data/wav/Visage/Visage/03-The Dancer.wav
/data/wav/Blondie/Atomic/01-Blondie Atomic.wav
/data/wav/Blondie/Atomic/02-Heart Of Glass.wav
/data/wav/Blondie/Atomic/03-Sunday Girl.wav
/data/wav/Blondie/Atomic/04-Call Me.wav
The script output/error messages are:
================================================== =========
Rays WAV to MP3 LAME wrapper
------------------------------------------------------------
Input Root = /data/wav
Output Root = /data/mp3
Bitrate =
Tempfile = /data/wav/razza.txt
------------------------------------------------------------
Files to convert:
/data/wav/ABC/Absolutely/03-All Of My Heart.wav
razza2.sh: line 106: /data/wav/ABC/Absolutely/03-All: No such file or directory
/data/wav/ABC/Absolutely/04-Tears Are Not Enough.wav
razza2.sh: line 106: /data/wav/ABC/Absolutely/04-Tears: No such file or directory
/data/wav/ABC/Absolutely/01-Poison Arrow.wav
razza2.sh: line 106: /data/wav/ABC/Absolutely/01-Poison: No such file or directory
/data/wav/ABC/Absolutely/02-The Look Of Love.wav
razza2.sh: line 106: /data/wav/ABC/Absolutely/02-The: No such file or directory
/data/wav/Visage/The Damned Don't Cry/04-Mind Of A Toy.wav
razza2.sh: line 106: /data/wav/Visage/The: No such file or directory
/data/wav/Visage/The Damned Don't Cry/03-Fade To Grey.wav
razza2.sh: line 106: /data/wav/Visage/The: No such file or directory
/data/wav/Visage/The Damned Don't Cry/02-Tar.wav
razza2.sh: line 106: /data/wav/Visage/The: No such file or directory
/data/wav/Visage/The Damned Don't Cry/01-Visage.wav
razza2.sh: line 106: /data/wav/Visage/The: No such file or directory
/data/wav/Visage/Visage/04-Tar.wav
razza2.sh: line 106: /data/wav/Visage/Visage/04-Tar.wav: cannot execute binary file
/data/wav/Visage/Visage/02-Blocks On Blocks.wav
razza2.sh: line 106: /data/wav/Visage/Visage/02-Blocks: No such file or directory
/data/wav/Visage/Visage/01-Visage.wav
razza2.sh: line 106: /data/wav/Visage/Visage/01-Visage.wav: cannot execute binary file
/data/wav/Visage/Visage/03-The Dancer.wav
razza2.sh: line 106: /data/wav/Visage/Visage/03-The: No such file or directory
/data/wav/Blondie/Atomic/01-Blondie Atomic.wav
razza2.sh: line 106: /data/wav/Blondie/Atomic/01-Blondie: No such file or directory
/data/wav/Blondie/Atomic/02-Heart Of Glass.wav
razza2.sh: line 106: /data/wav/Blondie/Atomic/02-Heart: No such file or directory
/data/wav/Blondie/Atomic/03-Sunday Girl.wav
razza2.sh: line 106: /data/wav/Blondie/Atomic/03-Sunday: No such file or directory
/data/wav/Blondie/Atomic/04-Call Me.wav
razza2.sh: line 106: /data/wav/Blondie/Atomic/04-Call: No such file or directory
================================================== ==========
I actually now think I have a more fundamental problem as the script seems to be trying to push the actual .wav file through sed as I have the error:
razza2.sh: line 106: /data/wav/Visage/Visage/01-Visage.wav: cannot execute binary file
/data/wav/Visage/Visage/03-The Dancer.wav
My sed is still complaining about spaces as evidenced in the following:
razza2.sh: line 106: /data/wav/Visage/Visage/03-The: No such file or directory
against the file:/data/wav/Visage/Visage/03-The Dancer.wav
And /data/convfile.txt contains nothing
Any views?