How to batch-unzip via terminal.

Sometimes when you download split-archives from the internet, archive creators seem to love putting a split-archive split into more archives and split these split archives into even more split archives. Zip and rar compression mixed, of course. When trying to extract these archives you might end up having a file structure similar to this:

file1.zip, file2.zip, file3.zip, file4.zip, file5.zip, file6.zip, etc.

With a simple terminal command you can batch-unzip all of them.

The command is: $ unzip <path-to-files>/\*.zip
Please mind the backslash. Otherwise the command doesn’t work.

After searching more through the web I found an alternative method, which could also be useful for different purposes: $ for var in *.zip; do unzip "$var";done

Basically this command finds all files with a .zip extension and unzips them. With a similar syntax you can, for example, delete every zip file in the current directory: $ for var in *.zip; do rm "$var";done

I found this technique here.


About this entry