use winrar command line to create zip archives
Asked Answered
C

3

47

I'm using the following winrar command line to create zip archives:

rar.exe a -df -ep -ag[yyyyMMddhhmmss] -ms[txt] C:\MyZipFile.zip C:\tmp\MyFiles*.txt

The archives created are in RAR format instead of ZIP. Is there a way to create regular ZIP and not RAR archives?

Carbonous answered 30/9, 2010 at 7:52 Comment(2)
Console RAR supports archives only in RAR format. ZIP and other formats are not supported. You should use winrar. acritum.com/winrar/console-rar-manualNymphet
warning for users: -df switch DELETES original files after archiving !!Clemenciaclemency
T
73

Make certain you are using WinRAR.exe and not Rar.exe.

If you are using the command line to do this make sure you type:

winrar a -afzip c:\test.zip c:\test.csv

not:

rar a -afzip c:\test.zip c:\test.csv

It works for me. I also got it to work in SSIS.

Touraine answered 16/12, 2010 at 19:8 Comment(2)
WARNING for users: -df switch DELETES original files after archiving !!Clemenciaclemency
Use the full path. Example: "C:\Program Files\WinRAR\WinRAR.exe" a D:\test.rar D:\testSclater
I
6

WinRAR has a detailed description of its command line syntax in its help files (WinRAR Help), chapter "Command line syntax".

All the commands such as "a" (add to an archive), "d" (delete from an archive), "e" (extract from an archive ignoring paths) and switches such as "-af" (specify whether to create a rar or a zip file), "-ad" (append archive name to destination path) or "-p" (encrypt the archive using password protection) are listed there.

There are quite a lot of options. I recommend reading the command line syntax rules when working with WinRAR via command lines.

In order to trigger WinRAR zip-packaging from within a MS Access database application, I use in the VBA code for example

Shell c:\Programme\WinRAR\winrar.exe a -afzip -p <AnyPasswordYouLike> "e:\MyStuff\TargetFolder\Output.zip" "e:\MyStuff\SourceFolder\Input.docx"

Of course, the file paths and names are ususally entered via variables, e.g. like

Dim strWinrarCommandline As String
'... and the other variables as well declared in advance, of course...     

strWinrarCommandline = strWinrarPathAndSwitches & "-p" & strPassword & " " & Chr(34) & strOutputFullName & Chr(34) & " " & Chr(34) & strInputFullName & Chr(34)

'And then call Winrar simply by:

Shell strWinrarCommandline
Isogamy answered 25/7, 2015 at 23:58 Comment(0)
C
0

So rar.exe is currently unable to create zip files by itself only by calling in the Windows version it is possible.

Colubrid answered 25/1, 2019 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.