DATE : 2018.11.19
1、参考
https://blog.csdn.net/dazhi_100/article/details/13298053
https://www.cnblogs.com/malianyong/p/7575380.html
https://blog.csdn.net/u013514928/article/details/79629937
https://www.cnblogs.com/dongzhuangdian/p/5510941.html
2、windows批处理读取文件内容到一个变量中
方法一:
for /f %%i in (. mp.txt) do (echo %%i) & echo %%i
方法二:
set /P OEM=<tmp.txt
方法二采用set命令亲测有效,并且很好用哦!
3、搜索当前目录下所有的文本文件
@echo off
for %%i in (*.txt) do echo "%%i"
pause
4、逐行读取文件到多个变量中
例如文件test.txt:
12
ww
qeq22
rtyyy
aaa65
ppo
lolo
如何读取每一行,并把每行内容以逗号为分界线拆分赋值给3个变量。
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1-3 delims=," %%i in (test.txt) do (
set BL1=%%i
set BL2=%%j
set BL3=%%k
echo Line1=!BL1! Line2=!BL2! Line3=!BL3!)
结果: