使用 winrar 命令行创建 zip 存档

发布于 2024-09-25 20:26:18 字数 203 浏览 0 评论 0原文

我使用以下 winrar 命令行来创建 zip 存档:

rar.exe a -df -ep -ag[yyyyMMddhhmmss] -ms[txt] C:\MyZipFile.zip C:\tmp\MyFiles*.txt

创建的存档采用 RAR 格式而不是 ZIP 格式。有没有办法创建常规 ZIP 而不是 RAR 存档?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

兰花执着 2024-10-02 20:26:18

确保您使用的是 WinRAR.exe 而不是 Rar.exe。

如果您使用命令行来执行此操作,请确保输入:

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

not:

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

It Works for me。我也让它在 SSIS 中工作。

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:

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

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

深海不蓝 2024-10-02 20:26:18

WinRAR 在其帮助文件(WinRAR 帮助)的“命令行语法”一章中有对其命令行语法的详细说明。

所有命令,例如“a”(添加到存档)、“d”(从存档中删除)、“e”(从存档中提取,忽略路径)以及诸如“-af”(指定是否创建存档)等开关此处列出了 (.rar 或 zip 文件)、“-ad”(将存档名称附加到目标路径)或“-p”(使用密码保护对存档进行加密)。

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

为了从 MS Access 数据库应用程序中触发 WinRAR zip 打包,我在 VBA 代码中使用,例如

Shell c:\Programme\WinRAR\winrar.exe a -afzip -p <AnyPasswordYouLike> "e:\MyStuff\TargetFolder\Output.zip" "e:\MyStuff\SourceFolder\Input.docx"

当然,文件路径和名称通常通过变量输入,例如

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)

“然后只需通过以下方式调用 Winrar:

Shell strWinrarCommandline

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
新一帅帅 2024-10-02 20:26:18

所以rar.exe目前无法自行创建zip文件,只有在Windows版本中调用才可能。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文