Bash scripting - sed, lame, etc.
Ok, so I find myself ripping audio CDs frequently, which I then lame to mp3's to put on my media player. I usually define the --ta and --tl (artist and album) ID3 tags and batch encode each album, but don't bother with the track tags as I'd have to do each one seperately. So, I'm working on a script to do all this for me, extracting info from 'pwd' etc. to fill in the blanks for --ta, --tl and --tt (track name). All is working well, except that I can't get sed to pass on the "\" character to lame to escape spaces. Here's what I've got so far: (trouble spot is bolded - no need to pay attention to the rest of it)
Code:
for f in * ; do lame $f $f.mp3 --ta `(pwd | sed 's/.*\/\(.*\)\/.*\/.*/\1/')` --tl `(pwd | sed 's/.*\/\(.*\)\/.*/\1/')` --tt `(echo $f | sed 's/...\(.*\)/\1/' | sed 's/_/\\ /g')` ; done |
Have you tried sed 's/_/\\ /g | sed 's/^/"/' | sed 's/$/"/' to put it in quotes? Might work
|
Quote:
Code:
lame: excess arg Bright |
You may need to double up on your backslashes. Don't forget that the shell will parse backslashes as escapes for the following character before passing strings to your command. To prevent that, you might want to use single-quotes around the string passed to lame.
|
Try leaving out the '\' and add double quotes.
Code:
--tt "`echo $f | sed 's/...\(.*\)/\1/' | sed 's/_/ /g'`" |
Hi Jinouchi
I feel it would be easier to assist if you gave an example of input and what your probable output will look like. |
Quote:
|
As I guess that script should work for you:
Code:
#!/bin/sh Albert_Ayler Anthony_Braxton Art_Ensemble_Of_Chicago Then album directories such as: Spirits Spiritual_Unity New_York_Eye_And_Ear_Control And finally consecutive tracks such as: 01_Witches_And_Devils.wav 02_Spirits.wav 03_Holy,_Holy.wav I'm not sure in which names you use underscores instead of spaces so I assumed you use them everywhere. *** Of course to produce MP3 files from WAV ones you have to use the commands similar to: Code:
lame --ta "$ta" --tl "$tl" --tt "$tt" $f |
Ok, I haven't tested all the new replies yet, but I thought I'd do as grail suggested and demonstrate exactly what I'm doing.
Working directory: Code:
/media/sdc1/music/three_days_grace/one_x/wav Code:
for f in * ; do lame $f $f.mp3 --ta `(pwd | sed 's/.*\/\(.*\)\/.*\/.*/\1/' | sed 's/^.\|_[a-z]/\U&/g')` --tl `(pwd | sed 's/.*\/\(.*\)\/.*/\1/' | sed 's/^.\|_[a-z]/\U&/g')` --tt `(echo $f | sed 's/...\(.*\)/\1/' | sed 's/^.\|_[a-z]/\U&/g')` --ti ../art/art.* ; done Code:
$ mplayer 01_its_all_over.mp3 |
Hi Jinouchi
I would like to start by saying I know little to nothing about lame :( But, assuming I understand the issue correctly, I believe this should work for you: Code:
find /media/sdc1/music/ -name "*wav" | not very useful:( I have also left the addition of the 'art' folder to you but I think that should be easily done |
Quote:
Quote:
Quote:
Code:
#!/bin/sh |
All times are GMT -5. The time now is 01:18 AM. |