2017-07-24 41 views

回答

1

以下批處理腳本會做你的需要。通過batchfile.bat x myFile.zip使用它,它遍歷所有文件以指定的前綴x開始,它們添加到一個結果文件​​使用type

@echo off 

set INVARGS=0 
if [%1] == [] set INVARGS=1 
if [%2] == [] set INVARGS=1 
if %INVARGS% == 1 (
    echo Usage: %0 ^<file_prefix^> ^<result_file^> 
    goto eof 
) 

set "prefix=%~1" 
set "resFile=%~2" 

rem create new empty file in directory of batch file: %~dp0 
break>"%resFile%" 
rem loop through all output line of the dir command, unset delimns 
rem so that space will not separate 
for /F "delims=" %%a in ('dir "%prefix%*" /b /s /a-d') do (
    rem don't use the result file 
    if not [%%a] == [%resFile%] (
     rem append the output to file 
     type "%%a">>"%resFile%" 
    ) 
) 

:eof 
+0

由於它的作品! – Ishai