how do I BASH this?

frank pirrone fpirrone at localnet.com
Fri Feb 22 01:58:30 EST 2002


My Dear Robert,

I truly am not worthy, so quickly asking for help.  After all the time I have
spent learning and using Linux I really let myself down on this one.

Shortly after broadcasting my plea, I thought I'd play around a bit with a couple
of solutions, and quickly came up with this terse and elegant result, which
incidentally converted literally hundreds of zipped files of music from the OLGA
and Maris collections into neatly named directories filled with songs in just
about 1.5 minutes!

    for f in *.zip; do unzip $f -d ${f%.zip}; done

Simply executed at the command prompt.

Anyway, thanks much for the prompt and interesting suggestion, Robert.  Looks
like your propeller beanie is on tight!

Frank

Robert Dege wrote:

> This is more of csh, and right off the top of my head:
>
> #!/bin/csh -f
>
> set DIR="."
>
> cd $DIR
>
> foreach FILE (`ls *.zip`)
>
> set ZIPNAME = `cut -d\. -f1`
>
> mkdir $ZIPNAME
> mv $ZIPNAME.zip $ZIPNAME
>
> cd $ZIPNAME
> unzip $ZIPNAME.zip
> cd ..
>
> end
>
> It's a crude script, but should suffice for what you're looking for.
>
> > Hi Guys!
> >
> > I have a large number of zipped files that have the names of various musical
> > acts with a collection of their songs inside:  aerosmith.zip, beatles.zip,
> > cream.zip...
> >
> > Problem is they were not zipped with paths, so a batch unzip would leave all
> > songs in the directory where the zip files were located instead of in named
> > subdirectories.
> >
> > What I want is to unzip with wild cards (unzip *.zip) and have directories
> > created with the name of the group - or the first part of the zipfile name
> > (aerosmith from aerosmith.zip), and the contents of the zipfile extracted
> > into that directory.
> >
> > Now, had I followed through on my intention of learning more about scripting
> > in BASH I probably would know how to do this, but alas...
> >
> > Please, my brothers in Linux, any assistance or suggestions?
> >
> > Frank
> >
> >
>
> Dege
>
> So Many Things in Life Would Be Really Funny
> .... If They Weren't Happening To Me



More information about the nflug mailing list