3

I looked for the answers in the list and did not find any matching.

What is the commandline to zip a file using Winrar, and then move it to a particular folder?

quack quixote
  • 42,186
  • 14
  • 105
  • 129
  • 7-zip ref: http://superuser.com/questions/5886/compressing-with-rar-vs-zip/5918 – nik Nov 01 '09 at 03:58
  • 3
    Don't say "zip" when you mean "compress". To "zip" something refers to the specific [ZIP format](http://en.wikipedia.org/wiki/ZIP_(file_format)) and is synonymous to creating a `.zip` file. – Daniel Andersson Mar 29 '12 at 13:51

4 Answers4

5

Though I found no documentation for it, I did manage to use winrar from the command line. I used the following syntax:

winrar a archiveName file1 file2 ....

to create an archive, and

winrar x archiveName

to extract the files from it in the current directory.

Eyal
  • 198
  • 8
  • yes, you can use winrar.exe from the command line with most but not ALL switches and options available to rar.exe –  Dec 15 '09 at 17:43
  • 1
    That creates a RAR file, not a ZIP file. – Synetech Aug 15 '11 at 05:59
  • 3
    This is in fact documented in the WinRAR Help File here is an online version of it: http://www.winrar-tr.com/winrar/Help/ENG/html/HELPCommandLineSyntax.htm – aolszowka Jul 06 '12 at 16:18
4

Per sqlsavvy's post on StackOverflow, it is possible to do using winrar.exe from the command line.

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

I confirm this works, however it pops up a gui progress bar during compress, instead of providing command line output.

jcwenger
  • 153
  • 5
3

WinRAR cannot be used from the command line, use RAR instead.

rar.exe (unlike WinRAR) cannot be used to create a zip archive.

for all possible RAR commands and switches refer to help (rar /?)

but here's how to use zip and unzip on the windows command line.

2

You could use these

add the folder "c:\latest data" to archive D:\Archives\Info.rar

WinRAR a D:\Archives\Info.rar "c:\latest data"

add the folder "c:\latest data" and subfolders to archive D:\Archives\Info.zip

WinRAR a -r D:\Archives\Info.zip "c:\latest data"

Note that WinRAR will use the archive extension (zip or rar) to decide the resulting archive format or you can use the switch above. WinRAR can be used fully in command line mode and there are a lot of command and switches for example you could add -ibck to avoid the progress bar. Also WinRAR will set the errorlevel to 0 for no errors, 1 for warnings and 2+ to signal several errors to ease the usage in batch files or scripts. All of this is explained in WinRAR help.

camilohe
  • 146
  • 2