use winrar command line to create zip archives

戏子无情 提交于 2019-12-03 04:05:08

问题


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?


回答1:


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.




回答2:


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



回答3:


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



来源:https://stackoverflow.com/questions/3828765/use-winrar-command-line-to-create-zip-archives

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!