Need to create a batch file to extract a zip folder using winzip executable commandline and copy to multiple places

StackOverflow https://stackoverflow.com/questions/22552104

  •  18-06-2023
  •  | 
  •  

Question

The batch file is indented to move the zip file from my local pc to server which is possible now and the problem is like winzip is not installed on the server so is it possible to move the winzip executable along with batch file and use its commandline to copy the extracted to multiple locations.

my zip file is on my local say \testmachine1\d$\zipfiles\test.zip

(Note: This zip file may contain multiple folders and file)

  1. the batchfile should ask the .

  2. and I would like to move the file to \testmachine2\d$\extractedfiles\

    \testmachine3\d$\extractedfiles\

    \testmachine4\d$\extractedfiles\

    .......................................................

    \testmachine[xx]\d$\extractedfiles\

My code looks like this:

  1. I am asking input on the zip file name, extract folder name, target and destination path along with a logfile path from the user

for /R "%destinationPath%" %%I in (%zipFileNamee%.zip") do ( echo %%I >> %LogFile% "%ProgramFiles%\WinZip\WinZip64.exe" -e" %%~dpI" "%destinationPath%\%extractFolder%\" >> %LogFile%

I understand there are other utilities to do this like 7zip. Its is prefereable to use winzip or 7zip for the same.

Was it helpful?

Solution

After a long try I found out that there is an wzunzip.exe avaliable as portable. I can keep this one along with my batch file and run the following code to unzip a file easily.

    for /R "%targetPath%" %%I in (%zipFileName%.zip) do (
wzunzip -ybc "%%I" "%targetPath%\%destinationPath%\" >> %LogFile%
)

This will find the specific file from the set of files and unzip it to the folder specified.

Cheers!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top