Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unzip files in original directory 1

Status
Not open for further replies.

jmarkus

Technical User
Oct 15, 2002
124
CA
I would like to have a script that finds all the zip files throughout a directory tree, and unzips them into directories named after the zip files, from the relative path.

I know:
find . -name "*zip" -exec dirname {} \;
will give me the directories where the zip files reside
find . -name "*zip" -exec unzip {} \;
will unzip all files to the directory I issued the command from

but how do I
find . -name "*zip" -exec unzip {} -d "relative path/filename-as-directory"

Thanks,
Jeff
 
find . -name '*zip' | while read f; do unzip $f -d `dirname $f`; done

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I don't think that does exactly what was required, it omits the creation of a directory based on the zip filename. Perhaps:

Code:
find . -name '*zip' | while read f; do unzip $f -d ${f%.zip}; done

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top