how do I BASH this?

Robert Dege rdege at cse.Buffalo.EDU
Fri Feb 22 00:28:06 EST 2002


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