Sometimes it is useful to verify the contents of a ZIP file before processing it further. One common check is to determine how many files are stored inside the archive. This can help identify whether the ZIP file is empty or possibly corrupted.
A simple VBScript can do this by using the Windows Shell namespace and reading the items inside the ZIP file. The script counts the files and displays the result in a message box.
Script example
Set objApp = CreateObject("Shell.Application")
set filesInzip=objApp.NameSpace("C:\test.zip").Items
Msgbox filesinzip.CountHow it works
The script creates a Shell.Application object, which gives access to Windows shell functions. Then it opens the ZIP file through NameSpace() and reads the collection of items inside the archive.
The .Items collection represents the files contained in the ZIP file. The .Count property returns how many entries are present.
Interpreting the result
If filesInZip.Count is 0, the ZIP file contains no files. In practice, that usually means one of two things:
- The ZIP file is empty.
- The ZIP file is corrupted and cannot be read properly.
This makes the check useful as a quick validation step before extracting or processing archive contents.
Notes
The script works with the Windows shell ZIP support, so it is simple and does not require additional software. However, because it depends on shell behavior, it is best suited for basic checks rather than advanced ZIP processing.
Conclusion
This VBScript provides a quick way to check how many files are inside a ZIP archive. It is a practical method for detecting empty or unreadable ZIP files before continuing with automation or file handling tasks.