Windows – Extract archive here, autodetect subfolder

7-zipextractwindows 7

I use 7-Zip under Windows 7 to extract all kind of archives. The ever-running problem is that there is not a single way to handle subfolders.

Some people create their archives like this (let's call it type A):

.
├── subfolder
│   ├── file 1
│   ├── file 2
│   └── ...
  • "Extract Here" will extract everything to subfolder/, which is fine;
  • "Extract to <Folder>" will create an extra subfolder level, which is annoying.

And other people create them like that (let's call it type B):

.
├── file1
├── file 2
├── ...
  • "Extract Here" will populate the current folder, which can bring a lot of mess if this folder already contains tons of other files, and which is very annoying;
  • "Extract to <Folder>" will create a subfolder and conveniently stuff it with the archive content, which is fine.

So this leaves two options: always choose to "Extract to <Folder>" and live with the extra subfolder for type A archives. Or open the archive before extracting it to check if this is a type A or B, and then appropriately select "Extract Here" or "Extract to <Folder>".

I usually do the latter, but I just discovered that KDE is offering a very handy Extract Archive Here, Autodetect Subfolder feature that automates that. It'll "Extract Here" for type A archives, and it'll "Extract to <Folder>" for type B archives.

I love this idea. Is there a Windows 7 tool offering this option? Preferably integrated in the explorer context menu? Maybe it's hidden somewhere in 7-Zip and I just didn't find it?

Best Answer

I believe the File paths section on the Advanced tab of WinRAR's archive extraction dialog might be what you're looking for:

WinRAR advanced archive extraction options 1


Edit: All right, I believe I have it. On WinRAR's Options / Settings / Compression tab, select Remove redundant folders from extraction path.

WinRAR advanced archive extraction options 2

Here's what it does, according to the help file:

Remove redundant folders from extraction path

This option works only in context menus, only for single selected archive with single folder and no files in archive root folder and only for "Extract to DestName\" command, where 'DestName' is a name of folder proposed by WinRAR and based on archive name. If all these conditions are met, this option removes the top level folder based on archive name from extraction path.

For example, if you have Pictures.rar containing all files in 'Samples' folder and if you unpack it with "Extract to Pictures\" context menu command, WinRAR will place files to "Pictures\Samples" if this option is off and to "Samples" if it is on. So it helps to save one click, avoiding necessity to open 'Pictures' folder, which contains nothing but 'Samples'.

This option introduces an additional delay in the beginning of extraction, because WinRAR needs to scan an archive and analyze its folder structure. Note that context menu still displays the archive based folder name even if it will be removed from path when extracting. Showing the correct folder already in context menu would introduce a potentially annoying delay between right clicking an archive and displaying the context menu.

I just tried it and it works brilliantly, so you end up with either <current_folder>\<archive_name> or <current_folder>\<subfolder_name>, and never <current_folder>\<archive_name>\<subfolder_name>.

As for 7-Zip, I see that a request to copy this feature from WinRAR has been pending for more than 3 years.

Related Question