2

I have downloaded a large number of .zip files and need to extract them using 7z (p7zip) at the command line. 7z x filename0001.zip is successful, but 7z x *.zip returns a "No files to process" error.

How can I unzip the files as a batch instead of one at a time?

Skyhawk
  • 14,200
  • 4
  • 53
  • 95

2 Answers2

4
for zip in *.zip; do
    7z x "$zip"
done
Icydog
  • 152
  • 1
  • 1
  • 7
2

Solution:

ls -1 *.zip | xargs -L 1 7z x

Explanation:

  1. ls -1 *.zip outputs a one-column list of zip files to stdout (ls dash-one, not ls dash-ell)
  2. xargs -L 1 takes each filename returned and passes it to 7z x as a parameter.
Skyhawk
  • 14,200
  • 4
  • 53
  • 95