這裏是我做了合併在一個文件中的所有文件*.bat
一個例子;所以你可以很容易地修改您的需求: 只要你需要修改變量Set "Filter_Ext=dlt"
和Set "MasterFolder=%userprofile%\desktop"
到你
@echo off
Mode 75,3 & Color 9E
Title Merge all *.bat in one file
Set "MasterFolder=%userprofile%\desktop"
Set "OutPut=Output_Merged_Files.txt"
Set "Filter_Ext=bat"
If exist "%OutPut%" Del "%OutPut%"
echo(
echo Please Wait a while we generate the output file ...
@For /f "delims=" %%a in ('Dir /s /b /A-D "%MasterFolder%\*.%Filter_Ext%"') Do (
cls
echo(
echo Please Wait a While ... Merging "%%~nxa" ...
(
echo ====================================================
echo Contents of "%%a"
echo ====================================================
Type "%%a"
echo(
)>> "%OutPut%"
)
Start "" "%OutPut%"
編輯合併所有.dlt在一個文件中
@echo off
Mode 75,3 & Color 9E
Title Merge all *.dlt in one file
Set "MasterFolder=%~1"
Set "OutPut=Output_Merged_Files.txt"
Set "Filter_Ext=dlt"
Set "KeyWord=Engine"
If exist "%OutPut%" Del "%OutPut%"
echo(
echo Please Wait a while we generate the output file ...
@For /f "delims=" %%a in ('Dir /s /b /A-D "%MasterFolder%\*.%Filter_Ext%" ^|find /I "%KeyWord%"') Do (
cls
echo(
echo Please Wait a While ... Merging "%%~nxa" ...
(
echo ====================================================
echo Contents of "%%a"
echo ====================================================
Type "%%a"
echo(
)>> "%OutPut%"
)
Start "" "%OutPut%"
每個
你的'for'語句中的'%f'必須是'%% f'。如果從批處理文件運行,則需要將「變量」上的'%'加倍。可悲的是,你的問題描述「這不是爲我工作」並沒有給我們提供很多線索,說明爲什麼這個過程沒有達到你期望的效果。 – Magoo
@Mangoo你會如何解決上述問題?只需簡單地考慮一下,你必須循環擴展名爲.dlt的所有文件,並且文件名必須包含過濾器'Engine'(例如:Filexxx_Engine_27_07_2017_01.dlt),然後使用type命令將所有這些文件合併到Engine_All.dlt中? –
你只想合併'* .dlt'文件?你的主文件夾位於哪裏? – Hackoo