本帖最后由 rockjean 于 2019-3-27 19:47 编辑
根据工作需要编写了如下代码,不知是否还可以更加精简?- @echo off
- date /t>date-of-today.txt
- for /f "tokens=1" %%i in (date-of-today.txt) do echo %%i>new-style-date.txt
- for /f "tokens=1-3 delims=/" %%i in (new-style-date.txt) do (
- mkdir "%%i %%j %%k"
- copy jerry.cmd "%%i %%j %%k"\swap-file.cmd
- copy data.txt "%%i %%j %%k"
- copy model.pdf "%%i %%j %%k"
- del date-of-today.txt&del new-style-date.txt
- cd "%%i %%j %%k")
- for /f "skip=14 tokens=*" %%1 in (swap-file.cmd) do echo %%1 >> rockjean.cmd
- del swap-file.cmd
- exit
- :
- @echo off
- :choice
- choice /C FQ /M "复制模版请按F,取消任务请按Q"
- if errorlevel 2 goto end
- if errorlevel 1 goto file
- :
- :reborn
- copy rockjean.cmd reborn.txt
- for /f "skip=23 tokens=*" %%1 in (reborn.txt) do echo %%1 >> second-swap.txt
- ren second-swap.txt reborn.cmd
- del reborn.txt
- del rockjean.cmd
- :
- :file
- for /f "skip=1 tokens=1,2,3" %%i in (data.txt) do copy model.pdf "%%i %%j%%k.pdf"
- ping 127.1 -n 2 >nul
- cls
- if errorlevel 1 echo 复制失败了,请检查哪里出了问题!
- if errorlevel 0 echo 恭喜你,复制成功啦!
- ping 127.1 -n 2 >nul
- cls
- goto reborn
- :
- @echo off
- :start
- choice /C BQ /M "复制空白请按B,取消任务请按Q"
- if errorlevel 2 goto end
- if errorlevel 1 goto blank
- :
- :blank
- for /f "skip=1 tokens=1" %%i in (data.txt) do copy model.pdf "%%i 空白.pdf"
- ping 127.1 -n 2 >nul
- cls
- if errorlevel 1 echo 复制失败了,请检查哪里出了问题!
- if errorlevel 0 echo 恭喜你,复制成功啦!
- ping 127.1 -n 2 >nul
- goto sd00250
- :
- :end
- echo 好的,下次继续~
- ping 127.1 -n 2 >nul
- cls
- echo 再见~
- ping 127.1 -n 2 >nul
- exit
- :
- :sd00250
- copy reborn.cmd sd00250.txt
- for /f "skip=29 tokens=*" %%1 in (sd00250.txt) do echo %%1 >> temp.txt
- ren temp.txt done.cmd
- del sd00250.txt
- del reborn.cmd
- @echo off
- echo 模版已经复制了,空白也复制了,再点开做什么?
- ping 127.1 -n 2 >nul
- echo 再见
- ping 127.1 -n 2 >nul
- del data.txt
- del model.*
- del done.cmd
复制代码
|