7zip:错误,问题和疑问

时间:2013-08-21 02:51:28

标签: windows batch-file unzip 7zip

我正在尝试运行批处理文件,该文件仅提取带有7z.exe的.jar文件 这是我的代码:

set location=%cd%
set filename=%location%\outputfolder
set unzip=%location\resources

cd %unzip%
7z e -o%filename% -ir!*.jar -y "%filename%\*.zip"

但它提供了一个例外:error: incorrect command line因此我删除了-ir!*.jar,然后又出现了另一个错误:error: cannot use absolute pathnames for this command所以我将-o%filename%更改为-oC:\outputfolder它的工作原理!!!!!!(这是我现在的脚本):

set location=%cd%
set filename=%location%\outputfolder
set unzip=%location\resources

cd %unzip%
7z e -oC:\outputfolder -y "%filename%\*.zip"

但我需要这些功能 如何解决?

1 个答案:

答案 0 :(得分:1)

用双引号试试,%cd%可能有空格:

7z e -o"%filename%" -i!*.jar -y "%filename%\*.zip"

帮助屏幕中的用法:

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Usage: 7za  [...]  [...]
       []


  a: Add files to archive
  b: Benchmark
  d: Delete files from archive
  e: Extract files from archive (without using directory names)
  l: List contents of archive
  t: Test integrity of archive
  u: Update files to archive
  x: eXtract files with full paths

  -ai[r[-|0]]{@listfile|!wildcard}: Include archives
  -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
  -bd: Disable percentage indicator
  -i[r[-|0]]{@listfile|!wildcard}: Include filenames
  -m{Parameters}: set compression Method
  -o{Directory}: set Output directory
  -p{Password}: set Password
  -r[-|0]: Recurse subdirectories
  -scs{UTF-8 | WIN | DOS}: set charset for list files
  -sfx[{name}]: Create SFX archive
  -si[{name}]: read data from stdin
  -slt: show technical information for l (List) command
  -so: write data to stdout
  -ssc[-]: set sensitive case mode
  -ssw: compress shared files
  -t{Type}: Set type of archive
  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
  -v{Size}[b|k|m|g]: Create volumes
  -w[{path}]: assign Work directory. Empty path means a temporary directory
  -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
  -y: assume Yes on all queries

enter image description here