Benn
Benn

Reputation: 5023

How to add files/folders to multiple zip files at once with WinRAR?

Is there any way to add files/folders to multiple zip files at once. For example:

Updates:

folder1
folder2
file1
file2

Archives:

archive1.zip
archive2.zip
archive3.zip

I need to add updates to all archives without opening all of them and pasting updates in there.

Any way to do this?

Or is there another archive program that can do this?

Upvotes: 0

Views: 4049

Answers (2)

Mofi
Mofi

Reputation: 49186

This can be done using a batch file and for example WinRAR.

@echo off
if not exist archive*.zip (
    echo There are no archive*.zip files to update in
    echo.
    echo %CD%
    echo.
    pause
    goto :EOF
)
set "ErrorCount=0"
for %%I in (archive*.zip) do (
    "%ProgramFiles%\WinRAR\WinRar.exe" u -afzip -cfg- -ep1 -ibck -inul -r -y "%%I" folder1 folder2 file1 file2
    if errorlevel 1 (
        echo Error on updating %%I
        set /A ErrorCount+=1
    )
)
if not "%ErrorCount%" == "0" (
    echo.
    pause
)
set "ErrorCount="

For each archive*.zip file WinRAR is called to update the ZIP file with the two folders and the two files.

The batch processing finishes without printing any message and without pausing if all ZIP files found could be updated successfully. Otherwise the batch file outputs which ZIP file could not be updated for example because of read-only attribute set, and pauses the batch processing before finishing so that the user can read the error message(s).

For details on the WinRAR command u and the used switches open in WinRAR from menu Help the Help topics, open on tab Contents the item Command line mode and read at least the help pages:

  • Command line syntax
  • Commands - Alphabetic commands list
  • Switches - Alphabetic switches list

For understanding the other used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

  • echo /?
  • for /?
  • goto /?
  • if /?
  • pause /?
  • set /?

Upvotes: 2

De.
De.

Reputation: 99

You can do it by using 7zip command line version

7z a archive1.zip dir\ -v10k -v15k -v2m @listfile.txt

this will do archive all files and folder is in that folder named 'dir' and first volume will be 10kb, second will be 15kb and others will be 2mb each except last and you can use a file that has list of all files named.

Upvotes: 0

Related Questions