- @echo off
- :st1
- rem 默认创建文档到当前文件夹
- set "ph1=%cd%\"
- set /p ph1=请输入创建文档的路径:(如:c:\test\datst)
- :st2
- set /p ph2=请输入你要合并的文档路径:(如:d:\test\datst)
- if not exist %ph2%\ echo;输入错误 & goto st2
- set /p new_name=请输入你要创建的文件名:
- set "new_name=%ph1%\%new_name%.csv"
- md "%ph1%" 2>nul
- setlocal enabledelayedexpansion
-
- :start
- set /a n+=1
- set /p filename%n%=请输入你想要合并的文档%n%:
- if not exist "%ph2%\!filename%n%!.csv" (
- if defined filename%n% (
- echo;输入错误 !filename%n%!.csv 文件不存在
- set "filename%n%="
- set/a n-=1
- set /p f=如需重新输入文件名请输入Y 退出按回车。
- if /i "!f!" neq "Y" goto end
- set "f="
- ) else set/a n-=1&goto end
- ) else (
- if !n! equ 1 (
- copy /b "%ph2%\!filename%n%!.csv" "%new_name%" >nul
- ) else more +3 "%ph2%\!filename%n%!.csv" >> "%new_name%"
- )
-
- goto start
- :end
- echo;%n% 个文件合并到 "%new_name%"
- endlocal
- set /p f=继续合并新文件输入Y 退出按回车。
- if /i "%f%" == "y" set f=&goto st1
复制代码
|