2013-08-21 92 views
0

我試圖運行提取與7z.exe
這裏只.jar文件的批處理文件是我的代碼:7zip的:錯誤,問題,問題

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

嘗試使用雙引號,%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

+0

似乎'-i *罐子! '不工作請幫助 – user2669763

+0

@ user2669763我測試了它,在這裏工作正常。我添加了幫助屏幕到我的答案。 – Endoro

+0

你能告訴我這是什麼嗎? 'SETLOCAL ENABLEDELAYEDEXPANSION'這是停止運行7zip的東西!有什麼辦法可以解除它嗎? – user2669763