Hi All, I'm trying to get a script together to batch process a bunch of ogg files. As part of it, I need to extract the tag information. ogginfo provides output like: dylan@scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue Jean.ogg" Processing file "David Bowie - Blue Jean.ogg"... New logical stream (#1, serial: 60e4a0f7): type vorbis Vorbis headers parsed for stream 1, information follows... Version: 0 Vendor: Xiph.Org libVorbis I 20030909 (1.0.1) Channels: 2 Rate: 44100 Nominal bitrate: 64.001000 kb/s Upper bitrate not set Lower bitrate not set User comments section follows... ALBUM=Best of Bowie ARTIST=David Bowie DATE=2002 DESCRIPTION= GENRE= KDE-ENCODER=kio_audiocd TITLE=Blue Jean TRACKNUMBER=30 Vorbis stream 1: Total data length: 1550426 bytes Playback length: 3m:11s Average bitrate: 64.668446 kbps Logical stream 1 ended dylan@scooby(1):/media/server/music/test> which I can grep lines from: dylan@scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue Jean.ogg" | grep ARTIST ARTIST=David Bowie dylan@scooby(1):/media/server/music/test> but I can't work out how to strip everything except the artist name (leaving just David Bowie) I figured I could use: dylan@scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue Jean.ogg" | grep ARTIST | sed 's/ ARTIST=//' ARTIST=David Bowie dylan@scooby(1):/media/server/music/test> but no! Suffice it to say I have tried various permutations of pipes and redirects, but I either get the output above, or bash admonishes me for ambiguous redirection. Any pointers would be greatfully received. Cheers Dylan -- "I see your Schwartz is as big as mine" -Dark Helmet
Op donderdag 9 september 2004 22:21, schreef Dylan:
dylan@scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue Jean.ogg" | grep ARTIST | sed 's/ ARTIST=//' ARTIST=David Bowie
Try something like: ..... | grep ARTIST | sed 's/ *ARTIST=//' -- Richard Bos Without a home the journey is endless
Dylan writes:
dylan@scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue=20 Jean.ogg" | grep ARTIST | sed 's/ ARTIST=3D//' ARTIST=3DDavid Bowie dylan@scooby(1):/media/server/music/test>
but no!
Suffice it to say I have tried various permutations of pipes and=20 redirects, but I either get the output above, or bash admonishes me for=20 ambiguous redirection.
That might be a tab character instead of 8 spaces before the ARTIST. Try using a sed expression like this: 's/^[ ]*ARTIST//' where between the square brackets is actually a space and a tab character. This will remove any number of leading spaces and tabs. -Ti
On Thursday 09 September 2004 22:45, Ti Kan wrote:
Dylan writes:
dylan@scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue=20 Jean.ogg" | grep ARTIST | sed 's/ ARTIST=3D//' ARTIST=3DDavid Bowie dylan@scooby(1):/media/server/music/test>
but no!
Suffice it to say I have tried various permutations of pipes and=20 redirects, but I either get the output above, or bash admonishes me for=20 ambiguous redirection.
That might be a tab character instead of 8 spaces before the ARTIST. Try using a sed expression like this: 's/^[ ]*ARTIST//' where between the square brackets is actually a space and a tab character. This will remove any number of leading spaces and tabs.
Good idea. Slightly improved that would be: 's/^[[:blank:]]*ARTIST//' ;) Cheers, Leen
On Thu, 9 Sep 2004, Dylan
which I can grep lines from:
dylan@scooby(1):/media/server/music/test> ogginfo "David Bowie - Blue Jean.ogg" | grep ARTIST ARTIST=David Bowie dylan@scooby(1):/media/server/music/test>
You could try this: artist=$(ogginfo "David Bowie - Blue Jean.ogg" | grep ARTIST) artist=${artist##*ARTIST=} Unfortunately, you need to do this as two steps as ${} needs a variable as the first parameter and will fail if you try and use $(command) instead. Regards, David Bolt PS. Sorry Dylan about the direct reply. Didn't notice I clicked reply-to-poster until after it had been sent :| -- Member of Team Acorn checking nodes at 63 Mnodes/s: http://www.distributed.net/ AMD 1800 1Gb WinXP/SuSE 9.1 | AMD 2400 160Mb SuSE 8.1 | AMD 2400 256Mb SuSE 9.0 AMD 1300 512Mb SuSE 9.0 | Falcon 14Mb TOS 4.02 | STE 4Mb TOS 1.62 RPC600 129Mb RISCOS 3.6 | A3010 4Mb RISCOS 3.11 | A4000 4Mb RISCOS 3.11
David, On Thursday 09 September 2004 19:15, David Bolt wrote:
...
You could try this:
artist=$(ogginfo "David Bowie - Blue Jean.ogg" | grep ARTIST) artist=${artist##*ARTIST=}
You'd be well advised to quote the right-hand sides of these assignments, too: artist="$(ogginfo "David Bowie - Blue Jean.ogg" | grep ARTIST)" artist="${artist##*ARTIST=}"
Unfortunately, you need to do this as two steps as ${} needs a variable as the first parameter and will fail if you try and use $(command) instead.
Regards, David Bolt
Randall Schulz
participants (6)
-
David Bolt
-
Dylan
-
Leendert Meyer
-
Randall R Schulz
-
Richard Bos
-
ti@amb.org