Page 1 of 1

Decompress Zip and recompress 7zip with Recursive Directory

Posted: 22 Nov 2011 03:21
by darioit
Hello,

I using two script for decompress ZIP file and re-compress using 7zip

The particularity of this script is that are inside Zip another zip file the batch recursively unzip all file and after compress all using 7Zip utility.

This is the 1st script Zip_to_7z.bat

Code: Select all

@echo off&setlocal enabledelayedexpansion
SET SevenZip=7za a -t7z -m0=LZMA -mx9 -mmt=2
set directory=%1
cd %directory%

   for /f "delims=" %%p in (
      'DIR /b *.zip'
   ) do (
      wzunzip -o "%%~dpnxp" "%%~dpnp" > nul
      cmd /c E:\test\Script\Zip_to_7z_recursive.bat "%%~np"
      %SevenZip% "%%~dpnp.7z" "%%~dpnp\*"
      rd /s /q "%%~np"
      del /q "%%~nxp"
     )


and this is the 2st script Zip_to_7z_recursive.bat

Code: Select all

@echo off&setlocal enabledelayedexpansion
set directory=%1
cd %directory%

   for /f "delims=" %%q in (
      'DIR /b *.zip'
   ) do (
      wzunzip -o "%%~dpnxq" "%%~dpnq" > nul
      cmd /c E:\test\Script\Zip_to_7z_recursive.bat "%%~nq"
      del /q "%%~nxq"
     )


I run it with command
E:\test\Script\Zip_to_7z E:\test\directory_with_zip_inside

The question is, this script are written correctly, or have I made ​​mistakes that can be adjust?

Regards
Dario

Re: Decompress Zip and recompress 7zip with Recursive Direct

Posted: 06 Dec 2011 01:15
by shiva
Hi,
to compress just use the command as
C:\WinRAR\Rar.exe a t DIR DIR\*

//DIR is the directory name

this will zip the DIR directory to .rar file

to Decompress just use the command as
C:\WinRAR\UnRAR.exe x a.zip

this will unzip the a.zip file as same format

first copy WinRAR directory into c drive and use this command lines to zip and unzip the files

Thank you
shiva :) :) :) :)