标题: [文本处理] 获取txt的行内容作为变量按指定格式生成对应的BAT文件 [打印本页]
作者: ccw4234312 时间: 2014-11-6 12:51 标题: 获取txt的行内容作为变量按指定格式生成对应的BAT文件
TXT 内容
5678932 a12.docx
1234564 b23.docx
1244444 c34.docx
1243424 d23.docx
N 行
BAT 内容
echo ^<attachment:a12.docx^> >> ~1.txt
echo ^<to_num:5678932^> >> ~1.txt
test
echo ^<attachment:b23.docx^> >> ~2.txt
echo ^<to_num:1234564^> >> ~2.txt
test
echo ^<attachment:c34.docx^> >> ~3.txt
echo ^<to_num:1244444^> >> ~3.txt
test
echo ^<attachment:d23.docx^> >> ~4.txt
echo ^<to_num:1243424^> >> ~4.txt
test
echo ^<attachment:xxxx.docx^> >> ~n.txt
echo ^<to_num:xxxx> >> ~n.txt
test
作者: cyq8886 时间: 2014-11-7 15:39
input.txt 是TXT 文件名- @echo off
- echo. >demo.bat
- set num=1
- setlocal enabledelayedexpansion
- for /F "eol= tokens=1* delims= " %%i in (input.txt) do (
- echo echo ^^^^^<attachment:%%j^^^^^> ^>^> ~!num!.txt >>demo.bat
- echo echo ^^^^^<to_num:%%i^^^^^> ^>^> ~!num!.txt >>demo.bat
- set /a num+=1
- )
- echo ok
- pause>nul
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |