【问题标题】:How to ZIP specific files from a folder using Winzip command line?如何使用 Winzip 命令行压缩文件夹中的特定文件?
【发布时间】:2013-09-04 06:00:09
【问题描述】:

使用此命令,我可以压缩文件夹中的所有文件:

wzzip.exe -a -p -r C:\DestinationPath\DataFiles_20130903.zip C:\SourcePath\*.*

但是,我的文件夹中有 .dat、.bat、.txt、.xls 文件。我只想压缩 .dat 和 .bat 文件。如何执行此操作?

谢谢。

【问题讨论】:

  • 也许使用 wzzip.exe -a -p -r C:\DestinationPath\DataFiles_20130903.zip C:\SourcePath\*.dat C:\SourcePath\*.bat
  • @r3ap3r 谢谢。它起作用了。但问题是,我必须保留 20 个文件。我必须用文件扩展名写 20 次。还有其他方法可以避免这种情况吗?
  • “我必须保留 20 个文件”是什么意思?你有 20 种不同的文件扩展名吗?请解释您的情况。
  • 20 只是一个例子。但我有多种类型的文件。我想让它可配置。可能我必须为此编写代码......对吗??
  • 是的,您必须编写代码以使命令可配置。

标签: command-line winzip


【解决方案1】:

使用此命令(针对问题中的特定场景):

wzzip.exe -a -p -r C:\DestinationPath\DataFiles_20130903.zip C:\SourcePath\*.dat C:\SourcePath\*.bat

有关 winZip 的更多命令行选项,请参阅以下链接:

winZip command line Reference 1

winZip command line Reference 2

要提供多个文件名,您还可以使用 @filename,其中 filename 是一个文件,其中包含要包含在 zip 文件中的文件列表。

如果您要使命令可配置,那么您可以要求调用您的命令的用户/其他程序选择文件扩展名,然后使用 java 将这些选定的扩展名写入 "filename" 文件代码或您喜欢的任何其他语言。

例如如果用户选择 batdat ,那么写 "C:\SourcePath\*.bat" 和 "C:\SourcePath\*.dat" 进入文件(假设文件名为fileExtensions.txt)并调用命令

wzzip.exe -a -p -r "C:\DestinationPath\DataFiles_20130903.zip" @"C:\SourcePath\fileExtensions.txt"

【讨论】:

    【解决方案2】:

    您可以使用 D7zip

    一个出色的 zipador 文件和文件夹 D7zip.exe

    下载链接

    https://drive.google.com/file/d/0B4bu9X3c-WZqdlVlZFV4Wl9QWDA/edit?usp=sharing

    如何使用

    压缩文件

    D7Zip.exe -z "c:\fileout.zip" -f "C:\filein.txt"
    

    压缩文件并输入密码

    D7Zip.exe -z "c:\fileout.zip" -f "C:\filein.txt" -s "123"
    

    压缩文件夹

    D7Zip.exe -z "c:\folderout.zip" -f "C:\folderin\"
    

    解压文件

    D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\"
    

    解压有密码的文件

    D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\" -s "123"
    

    按扩展名解压文件

    D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\*.txt"
    

    解压文件而不要求确认替换

    D7Zip.exe -u "c:\fileout.zip" -f "c:\folderout\" -r
    

    帮助

    D7Zip.exe -?
    

    Delmar Grande 的 D7Zip.exe。

    【讨论】:

      【解决方案3】:

      如果上面给出的命令行是正确的,那就试试吧:但检查路径。

      @echo off
      pushd "C:\SourcePath"
      "c:\program files\winzip\wzzip.exe" -a -p -r "C:\DestinationPath\DataFiles_20130903.zip" *.dat *.bat
      popd
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多