Notifications
Clear all

Extract several zip files, each in a new folder with the same name


 wild
(@wild)
Member Admin
Joined: 2 months ago
Posts: 291
Topic starter  

You should be able to use unzip's -d option to set an alternate directory for the archive contents.

unzip -d a a.zip
unzip -d b b.zip

and so on. Within a find expression, you should be able to derive the name for the directory from the name of the zipfile using shell parameter expansion e.g.

find . -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;

Test it first by adding an echo i.e.

find . -name '*.zip' -exec sh -c 'echo unzip -d "${1%.*}" "$1"' _ {} \;

or something like

while read -rd $'\0' f; do 
  unzip -d "${f%.*}" "$f"
done < <(find . -name '*.zip' -print0)

   
Quote
Topic Tags
Share: