使用winrar命令行创建zip档案。

时间:2021-12-11 09:32:05

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

我使用下面的winrar命令行来创建zip归档:

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?

创建的档案是用RAR格式而不是ZIP。有没有一种方法可以创建普通的ZIP而不是RAR归档?

2 个解决方案

#1


46  

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

确保你使用的是WinRAR。exe而不是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.

它适合我。我还让它在SSIS中工作。

#2


2  

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

WinRAR在其帮助文件(WinRAR help)中详细描述了它的命令行语法,“命令行语法”。

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.

所有的命令,如“a”(添加到存档),“d”(删除存档),“e”(从存档忽略路径)和开关等“对焦”(指定是否创建一个rar或zip文件),“广告”(档案名称附加到目的地的路径)或“p”(加密档案使用密码保护)列出。

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

有很多选择。我建议在使用命令行与WinRAR合作时阅读命令行语法规则。

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

为了从MS Access数据库应用程序中触发WinRAR压缩包,我在VBA代码中使用。

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

#1


46  

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

确保你使用的是WinRAR。exe而不是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.

它适合我。我还让它在SSIS中工作。

#2


2  

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

WinRAR在其帮助文件(WinRAR help)中详细描述了它的命令行语法,“命令行语法”。

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.

所有的命令,如“a”(添加到存档),“d”(删除存档),“e”(从存档忽略路径)和开关等“对焦”(指定是否创建一个rar或zip文件),“广告”(档案名称附加到目的地的路径)或“p”(加密档案使用密码保护)列出。

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

有很多选择。我建议在使用命令行与WinRAR合作时阅读命令行语法规则。

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

为了从MS Access数据库应用程序中触发WinRAR压缩包,我在VBA代码中使用。

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