How to programmatically unzip archives into my own directories on Windows using the DOS command?

There are many ways to unzip archives on Unix:

The goal is to find all the archives and unzip them in your own directory (where each archive is found) on Windows .
Additionally:

  • delete the archive after unpacking.
  • write down any error message if one archive has a problem when unpacking.

I am looking for a regular DOS command line using, for example, 7z.exe (which is included in the portable version of PeaZip ).

+6
source share
2 answers

I took this sevenzip project stream from the command line with a slight modification:

 FOR /R %I IN (*src.zip) DO (C:\apps\peazip_portable-3.8.WINDOWS\res\7z\7z.exe x "%I" -aoa -o"%~dpI\*" |c:\windows\system32\find.exe "Everything is Ok" >nul &&DEL /F "%I" ||ECHO.%I : EXTRACT FAIL - ARC NOT DELETED >>ERR.TXT) 

(multi-line visibility)

 FOR /R %I IN (*src.zip) DO ( \ C:\apps\peazip_portable-3.8.WINDOWS\res\7z\7z.exe x "%I" -aoa -o"%~dpI\*" |c:\windows\system32\find.exe "Everything is Ok" >nul &&DEL /F "%I" ||ECHO.%I : EXTRACT FAIL - ARC NOT DELETED >>ERR.TXT) 

Notes:

  • I prefer to specify " c:\windows\system32\find.exe " instead of just FIND , because I have another " find.exe " on my PATH (from msysgit , or gow ).
  • delete the " &&DEL /F "%I" " part if you want to keep the archives in place.

I just unzipped 470 " src.zip " from the Rational Team Concert SDK in two minutes with this one layer!

+7
source

This is an old question, but someone might find this helpful. This method worked for me using WinZip and the WinZip command-line add-on, which are available on the WinZip site for registered users.

 FOR /R %I IN (*.zip) DO (C:\Program Files (x86)\winzip\wzunzip.exe -ye "%I" "%~pI") 

-ye will indicate the folder after the zip file. % i is the name of the zip file% ~ pI is the destination of the contents of the zip file

Unable to add debug messages in previous answer. Run the command inside the folder where all your subfolders containing your zip files are stored.

0
source

Source: https://habr.com/ru/post/912939/


All Articles