t (Test integrity of archive) command
Tests archive files.
Example
7z t archive.zip *.doc -r
tests *.doc files in archive
archive.zip .
Notes
7-Zip doesn't use the system wildcard parser. 7-Zip doesn't
follow the archaic rule by which *.* means any file. 7-Zip treats
*.* as matching the name of any file that has an extension. To process
all files, you must use a * wildcard.
Switches that can be used with this command
-ai (Include archives)
-an (Disable parsing of archive_name)
-ax (Exclude archives)
-bb (Set output log level)
-i (Include)
-p (Set Password)
-r (Recurse)
-sns (Store NTFS alternate Streams)
-stx (Exclude archive type)
-t (Type of archive)
-x (Exclude)
-scrc (Set hash method)
Notes from this site
Not part of the 7-Zip manual. Written by this site; examples checked with 7-Zip 26.04.
Quick examples
The official Linux and macOS console binary is 7zz; the commands differ from Windows only by that name.
7zz t archive.7z # whole archive
7zz t archive.7z -r '*.doc' # only .doc files, also in subfolders
7zz t -p archive.7z # prompts for the password
7zz t -pSECRET archive.7z # for scripts (SECRET shows in the process list)
7zz t -bso0 -bsp0 archive.7z # no normal output and no progress, for cron
# Linux/macOS script: silent when fine; any non-zero exit code (1 warning, 2 fatal) is a failure here
7zz t backup.7z -bso0 || { echo FAILED; exit 1; }
# every archive in a folder
for f in *.7z; do 7zz t -bso0 "$f" || echo "BAD $f"; done
# Windows batch
7z t backup.7z -bso0 & if errorlevel 1 echo FAILED
How do I tell in a script that the archive is intact?
A good archive ends with Everything is Ok and exit code 0. A damaged one printed Open ERROR: Cannot open the file as [7z] archive and returned 2; a wrong password reports Data Error in encrypted file. Wrong password? and also returns 2. Scripts should check the exit code; see exit codes .
-bso0 turns off normal output so a cron job stays quiet; errors still print (see -bs ).
What a pass means
The test checks the archive against its own stored CRCs, not against your source files. Exit codes: 0 no error, 1 warning, 2 fatal error, 7 command line error, 8 not enough memory, 255 stopped by the user. || treats any non-zero code as failure, which is usually what a backup script wants.
Checksums
For a checksum of all the data in the archive, add -scrc , for example 7zz t archive.7z -scrcSHA256, and compare the "for data" line.
Common mistakes
Testing with a pattern that matches nothing: 7zz t archive.zip nomatch printed Files: 0, still said Everything is Ok and returned 0. Check the Files count, or test the whole archive.
Forgetting -r : without it *.doc matches only files at the top level of the archive.
Testing a split archive from the wrong part: give the first part, archive.7z.001 (or vol.zip.001 for a split zip), and 7-Zip tests all parts. Starting at .002 fails, and so does a missing part (exit 2).
Related pages