文本文件合併bat

@echo off

rem ----------------------------------------------------------------------------
rem ADD_LINE設定空行數
rem ----------------------------------------------------------------------------
set ADD_LINE=2
set OUTPUT_FILE=merge.txt
set SOURCE_FILE=*.txt
set WORK_FOLDER=work

pushd %~dp0
cd ".\"%WORK_FOLDER%

if %ADD_LINE%==0 (
    copy %SOURCE_FILE% %OUTPUT_FILE%
    exit
)

type nul>%OUTPUT_FILE%
for /f %%a in ('dir %SOURCE_FILE% /b /ON') do (
    if not %%a==%OUTPUT_FILE% (
        copy %OUTPUT_FILE%+%%a %OUTPUT_FILE%
        for /l %%i in (1,1,%ADD_LINE%) do (
            echo:>>%OUTPUT_FILE%
        )
    )
)

pause
相關文章
相關標籤/搜索