How can I get the total number of files in multiple zip files at the same time? I have around 1000 zipfiles in one folder and would like to know the total amount of files inside them all combined. How can I do this? I've tried

zipinfo -t file.zip 

But that only gives me the number from that archive, I've also tried

zipinfo -t *zip/?.zip

and gets

caution: filename not matched:  Jo Coo-Day-Sun.zip
caution: filename not matched:  Micke Mouse-Stare-Well-Pt1.zip
caution: filename not matched:  Micke Mouse Cooley-Stare-Well-Pt2.zip

Any suggestions?

  • You need to quote the expansion. Read the man page for zip info. zip info -t "*zip" will run on all zip files in the $PWD. This give infer for each zip archive however if you want a combined total you need to script is so the count for each can be added up. Commented Feb 1, 2016 at 18:15
  • Thanks! Yeah i noticed that they were listed individual. Do you how that script may look? Is it hard to make for someone that has very little experience in this area?
    – Halalbin
    Commented Feb 1, 2016 at 18:26

1 Answer 1


There is certainly more then one way to do this and what I'm presenting is not necessarily the best way, however it is a way that works. Create a bash script using the following code.

for f in *.zip; do
    x="$(zipinfo -t "$f" | awk '{print $1}')"
    c=$(( $c + $x ))
echo "The total file count is:" $c

Then you'd cd to the directory containing the zip archive files and execute the bash script by its name if it's in the $PATH or its pathname if it's not in the $PATH.

Say you save it as getfilecount in your $HOME directory, which normally is not in your $PATH you'd cd to the directory containing the zip archive files and then use:


To make the bash script create an empty text file, e.g. touch getfilecount and then open the file, e.g. open getfilecount add the code above via copy and paste and save it. Now make the file executable, e.g chmod +x getfilecount and now you can use it as is or place it in a directory that's in the $PATH, then all you'd need to type once changing to the directory containing the zip archive files is: getfilecount

Below is sample output to show the difference between using single commands method and a bash script.

Issuing commands, one at a time:

$ cd zipfiles
$ ls
codetest.zip    destination.zip helloworld.zip  source.zip
$ zipinfo -t "*.zip"
1 file, 820 bytes uncompressed, 437 bytes compressed:  46.7%

1 file, 0 bytes uncompressed, 0 bytes compressed:  0.0%

6 files, 12385 bytes uncompressed, 895 bytes compressed:  92.8%

101 files, 0 bytes uncompressed, 0 bytes compressed:  0.0%

4 archives were successfully processed.

Using getfilecount (when the bash script is in the $PATH):

$ cd zipfiles
$ getfilecount

The total file count is: 109
  • Thanks a lot! I was about to save the output from zipinfo, then "learning" regex to get the first sequence of numbers. And after somehow add them together. This saved me hours! Really simple to execute to, cd to my folder, touch getfilecount, copy+paste, press enter and it was done after a couple of seconds. I had around 40 000 files inside the zip archives. Thanks again for helping me out!
    – Halalbin
    Commented Feb 1, 2016 at 19:19
  • @Halalbin, Glad it worked for you however do keep "learning" regex and such, as it can be invaluable when scripting. :) BTW questions such as this are probably better asked on Stack Overflow. Commented Feb 1, 2016 at 19:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .