extracting multiple files with 7zip & creating a folder for each
Asked Answered
A

2

9

I have like 300 zip files (but may get other kind of archives in the future) in a folder and I need to unzip each one in a subfolder of the archive name.

I've tried native 7zip options in command line but nothing worked yet, did not get any luck in the 7zip FAQ either. Finally tried "forfiles" in batch and that seemed to provide better results, but cannot manage to get it working.

Here is the last thing I tried :

forfiles /m *.zip /c "C:\tool\7-Zip\7z.exe e -o@path @file"

But cannot manage to get any result, this is what I get with a 4 zip sample:

C:\Users\tracto\test>forfiles /m *.zip /c "C:\tool\7-Zip\7z.exe e -o@path @file"

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Error:
Incorrect command line

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Error:
Incorrect command line

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Error:
Incorrect command line

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Error:
Incorrect command line

I'll take any help you can offer, thx in advance.

Araucanian answered 12/9, 2019 at 12:27 Comment(0)
M
15

There is a built in command for this in 7zip.

This command line will extract all zip files in the current directory (e *.zip) to directories with names of archives (-o*).

 C:\tool\7-Zip\7z.exe e "*.zip" -o*
Mopes answered 12/9, 2019 at 12:47 Comment(5)
Ok in fact I've tried that before but it wasn't creating folders ... I've finally updated 7zip and ... well it worked that way, thx :)Araucanian
works nicely, but can't manage to create a reg commande with it if you have any clue ... [HKEY_CLASSES_ROOT\Directory\shell\unziptofolders\command] @="cmd /c \"C:\\tool\\7-Zip\\7z.exe e %1*.zip -o*\""Araucanian
Try to redirect the output to a file by adding to see errors: >Log.txt.Mopes
For those on Linux, I had to do: 7z e "*.zip" -o* (adding in the quotes).Janeyjangle
you may also want to use the x flag instead of the e one, this will extract the archives by keeping the internal folder structure: 7z x "*.zip" -o*Boettcher
A
1

In fact I did a batch that is getting called by registry :

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\unziptofolders]
"icon"="%SystemRoot%\\system32\\shell32.dll,45"
@="Unzip All"

[HKEY_CLASSES_ROOT\Directory\shell\unziptofolders\command]
@="cmd /min /c \"C:\\tool\\7-Zip\\7z-grpfolder.bat %1\""

with in that batch the following :

@echo off
cd %1
C:\tool\7-Zip\7z.exe e *.zip -o*

works like a charm.

Thanks a lot for your help !

Araucanian answered 12/9, 2019 at 13:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.