7z command line has a very fast search feature allowing to find files contained in a compressed folder. This is the syntax:

7z l mycompressedfile.7z fileiwant.txt -r

It works also on multiple compressed files contained in a folder:

7z l *.7z fileiwant.txt -r

My question is how can apply this feature to all the files contained in a folder or disk, recursing all the subfolders? for example, I want to search "fileiwant.txt" in all the zip files contained in any folder on disk D:

7z l [unknown option] d:\*.7z fileiwant.txt -r

I couldn't find any option to do that, beside scripting in PowerShell, but it's complicated, I'd like a single line, easy to remember.

Many thanks for the help


The windows command Forfiles can let you run a command over files in a directory and its subdirectories.

The syntax for your needs is the following :

forfiles /s /M *.7z /c "cmd /c 7z l @file fileiwant.txt -r"

Forfiles iterate over all .7z files (/M *.7z) in the current directory and its subdirectories (/s). It apply your 7z command for each files (/c "cmd /c 7z l @file fileiwant.txt -r")

Source : https://ss64.com/nt/forfiles.html

  • Thanks, upvoted. Similar but more succinct than the PS I found as I stated in my Q, i.e. foreach ($myzip in cmd /C where /R d:\ *.7z) { 7z l $myzip fileiwant.txt -r } However I was looking for a 7z option doing all of it without other commands, bc that gives also a general report of all the inspected archives which is lost when you process one by one. I found the option, see the answer to my original Q. Thanks anyway ;) – Anton M May 3 at 15:15

I found the option in 7z, thanks to the author of 7-zip

here is the syntax:

7z l -an -air!d:\*.zip fileiwant.txt -r

it is fast and produces a single global report of all inspected archives

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.