[Gllug] More grep stuff

Dylan dylan at dylan.me.uk
Fri Sep 10 21:46:04 UTC 2004


On Friday 10 Sep 2004 22:29 pm, Stuart Sears wrote:
> On Friday 10 September 2004 21:23, Dylan wrote:
> > Hi All,
> >
> > In my quest to extract tag info from ogg files, I have encountered
> > another problem...
> >
> > oggenc allows multiple comment arguments, so I figured I would:
> >
> > for comment in `ogginfo <file> | grep =
> > do
>
> the for command assigns each individual word to $comment in turn

Yes, I'd gathered that

>
> >   comments="-c \"comment\" "$comments
> >   done
> >
> > but this produces, for example:
> >
> > -c "TRACKNUMBER=7" -c "Love" -c "In" -c "Not" -c "TITLE=Im" -c
> > "KDE-ENCODER=kio_audiocd" -c "GENRE=" -c "DESCRIPTION=" -c
> > "ARTIST=10cc" -c "ALBUM=Milestones"
> >
> > instead of:
> >
> > -c "TRACKNUMBER=7" "TITLE=Im Not In Love" -c
> > "KDE-ENCODER=kio_audiocd" -c "GENRE=" -c "DESCRIPTION=" -c
> > "ARTIST=10cc" -c "ALBUM=Milestones"
>
> so you want to put all of the tags into one long comment tag?

Well, since -c "ARTIST=10cc" and -a "10cc" are equivalent wrt to what 
data gets entered into the ogg file I don't see the difference

>
> > Obviously, any of the comments can have spaces in the rhs, but I
> > can't figure out how to get the lines with spaces to come out
> > complete. I'm especially confused since:
>
> how about this (as a small script. Also attached)
> #!/bin/bash
> # take a filename as the first argument:
> file=$1
> comments=""
> # the next line will wrap. It shouldn't be kept that way!
> for line in `ogginfo $file | grep = |cut -f2| sed -e 's,^,-c \"&,' -e
> 's,$, \",'`; do
> #the 'cut' command strips the leading tab
> #(assuming it is a tab, It is in my oggs)

But it seems that the for construction is doing this anyway - hence 
introducing the problem

> #the 'sed' bit puts the -c and quotes at the
> # beginning and end of the line.
> comments="$comments $line"
> done
> # output result on stdout to check it.
> echo "comment tags are: "$comments

dylan at scooby(1):/media/server/music/test> ./comments.sh "10cc - Im Not 
In Love.ogg"
comments tags are:
dylan at scooby(1):/media/server/music/test> ogginfo "10cc - Im Not In 
Love.ogg"
Processing file "10cc - Im Not In Love.ogg"...

New logical stream (#1, serial: 329cf3b5): 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=Milestones
        ARTIST=10cc
        DESCRIPTION=
        GENRE=
        KDE-ENCODER=kio_audiocd
        TITLE=Im Not In Love
        TRACKNUMBER=7
Vorbis stream 1:
        Total data length: 2772806 bytes
        Playback length: 6m:05s
        Average bitrate: 60.651972 kbps
Logical stream 1 ended
dylan at scooby(1):/media/server/music/test>

hmmm

no closer as yet, but thanks anyway

Dylan
-- 
"I see your Schwartz is as big as mine" 
                                  -Dark Helmet
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list