How to search an archive file without extracting it on Windows 10
Archive files are easy to extract and there are plenty of free apps for Windows 10 that you can use. Extracting an archive isn’t hard though it can take time if it’s a very large archive. If you’d rather take a look inside the archive before you extract it, maybe search it for a particular file, you can use 7-Zip for the job. ALl you need is a command prompt command.
Install 7-Zip and add to path
If you don’t use 7-Zip already, install it. To make it easier to use, you should add it to the Path variable. Open File Explorer and enter the following in the location bar. Go to Advanced System Settings, and click ‘Environment variables’ on the ‘Advanced’ tab.
Control Panel\System and Security\System
Select ‘Path’ under User variables and click the Edit button. On the new window, click the New button and select the folder that 7-Zip is installed in. Click OK.
Search an archive
This will work for all archive types that 7-Zip supports and it supports most of them. Open the folder that contains the archive file you want to search in File Explorer. Click inside the location bar and enter ‘cmd’. Tap enter and a Command Prompt window will open. Use the following command to search the archive.
Command
7z l name-of-archive name-of-file -r
Example
7z l ffmpeg-20200218-ebee808-win64-static.zip ffmpeg.exe -r
The command will return how many files it found with the name you entered, and where the file is located in the archive. It will also return a little information about the archive e.g., its size and type.
If you’re not sure what the name of a file is but you know part of the name, you can modify the command and use a wildcard to search for it. For example, you can use the following command to search for all files that start with ‘ff’ and have any extension.
7z l ffmpeg-20200218-ebee808-win64-static.zip ff*.* -r
If you’re looking for a way to search inside a file e.g., there’s a notepad file in the archive and you want to search for it without extracting the archive, you won’t be able to. Your only option is to extract it. Even then, you’d need an app that can search the file without opening it. If you suspect the file is malicious, you can try scanning it with VirusTotal.
To be safe, make sure the archive you download is from a trustworthy source i.e., a trusted website, developer, or friend.
Thank you for sharing useful technique. Here’s how I have expanded on it. Excel files with the .xlsx extension are actually zip files so you can use this same technique on them. I want to know which of my Excel files contain Power Queries, which would reside in a queryTables folder.
7z L *.xlsx querytables -r | findstr /I “xml listing”
This method pipes the output through the findstr command so only lines that contain “xml” or “listing” are shown.