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?
Best Answer
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.
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'dcd
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.gchmod +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:
Using
getfilecount
(when thebash
script is in the$PATH
):