-an (Disable parsing of archive_name) switch
Disables parsing of the archive_name field on the command line.
This switch must be used with the
-ai (Include archives) switch .
If you use a file list for your archives, you specify it with the -ai switch,
so you need to disable parsing of archive_name field from command line.
Syntax
-an
Examples
7z t -an -ai!*.7z -ax!a*.7z
tests all *.7z archives,
except a*.7z archives.
Commands that can be used with this switch
e (Extract) ,
l (List) ,
t (Test) ,
x (Extract with full paths)
See also
Switches:
-ai (Include archives)
-ax (Exclude archives)
Notes from this site
Not part of the 7-Zip manual. Written by this site; examples checked with 7-Zip 26.04.
Vendor link warning: the "See also" link to exclude.htm points to -x , which filters files inside archives. The switch that excludes archives is -ax .
When do I need -an?
When archives come only from -ai and you give no archive name on the command line, add -an. It tells 7-Zip not to read an archive name from the command line, so every archive comes from -ai. This is true for wildcards as well as list files. With 7zz 26.04, 7zz t -ai'!*.7z' (no -an, no name) stops with "Cannot find archive name", while 7zz t a1.7z -ai'!b*.7z' (a name, no -an) ran and tested both a1.7z and b1.7z.
Quick examples
Use 7z on Windows and 7zz (the official console binary) on Linux/macOS, with the pattern quoted. In Windows cmd use the unquoted form of line 1.
7z t -an -ai!*.7z
7zz t -an -ai'!*.7z' -ax'!a*.7z'
7zz t -an -ai@archives.txt
7zz x -an -ai'!*.7z' -o'*'
With a1.7z and b1.7z in the folder, line 2 tests only b1.7z. Line 3 reads archive names from archives.txt, one per line. Line 4 extracts every archive into a folder named after it, handy for a downloads folder.
Extra file names after the switches still apply inside each archive: 7zz x -an -ai'!*.7z' -o'*' b.txt extracts only b.txt from the archives that contain it.
Common mistakes
Leaving -an out when there is no archive name on the command line: 7-Zip stops with "Cannot find archive name".
Using -an with an -ai pattern that matches nothing, or with no -ai at all (7zz t -an): it prints "Scanning the drive for archives:" and stops with "Cannot find archive". Check the pattern and the current folder.
Using it with the a (Add) command; it works only with e, l, t and x.