Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use winrar command line to create zip archives

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?

like image 217
Frangiskos Avatar asked Sep 30 '10 07:09

Frangiskos


People also ask

How use WinRAR command line Windows?

To get a listing of the options for the rar and unrar commands, open a command window, cd to the WinRAR directory, and type rar or unrar and then press enter (rar /? or rar help may also be used, use rar >rar_cmds. txt or unrar >unrar_cmds. txt to print the command options to a file).

How do I create an archive in WinRAR?

To create a file with WinRAR, first select all of the files you want to add. Then, right-click the files and select "Add to archive…". When the WinRAR window appears, make sure you select the "ZIP" archive format. Press "OK" and a .

Does WinRAR have command line?

The RAR command line version is convenient when you need to call RAR from BAT and CMD files or to use it at the command prompt.


2 Answers

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.

like image 112
sqlsavvy Avatar answered Sep 19 '22 14:09

sqlsavvy


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 
like image 22
Christian Geiselmann Avatar answered Sep 20 '22 14:09

Christian Geiselmann