how unzip many zip files found in many subdirectories, all in a certain different directory

0

i have a list of zip files, which each zip file in it has also some other zip files, and so on. I need to extract them all, with an ubuntu shell command, and get only the files with the extension *.pdf, into a new empty directory.

This is where i managed to come, i have tried unzip -l "*.zip"

vipoxou

Posted 2018-10-12T10:12:41.887

Reputation: 3

Answers

2

From How do I recusively unzip nested ZIP files? comes this one-liner :

while [ "`find . -type f -name '*.zip' | wc -l`" -gt 0 ]; do find -type f -name "*.zip" -exec unzip -- '{}' \; -exec rm -- '{}' \;; done

This removes all zip files that were done in order to avoid infinite loops. If you want to conserve these files, take first a backup.

harrymc

Posted 2018-10-12T10:12:41.887

Reputation: 306 093

but how do i only keep files with the extension .pdf? – vipoxou – 2018-10-12T11:10:23.007

1The above extracts all files. To extract only zip and pdf replace the command -exec unzip -- '{}' by the two commands -exec unzip -- '{}' "*.zip" \; -exec unzip -- '{}' "*.pdf.` – harrymc – 2018-10-12T13:52:55.103