43

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?

Zhaph - Ben Duguid
  • 25,726
  • 4
  • 75
  • 111
Frangiskos
  • 586
  • 1
  • 4
  • 6
  • 2
    Console RAR supports archives only in RAR format. ZIP and other formats are not supported. You should use winrar. http://acritum.com/winrar/console-rar-manual – Daniel B Oct 17 '13 at 18:48
  • 9
    warning for users: -df switch DELETES original files after archiving !! – Amr Lotfy Sep 04 '14 at 09:24

3 Answers3

60

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:

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

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

cuixiping
  • 18,858
  • 4
  • 71
  • 90
sqlsavvy
  • 609
  • 5
  • 3
5

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
0

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

Ricardo Bohner
  • 217
  • 2
  • 8