请解释是否可以通过这种方式从文本文件中移动一行 我想把每一行都作为一些字符串变量。 我想用这个“变量行”做我想要的,所以我需要把这一行删除 tf.txt,在第二行将tehnicaly后的第一行tf.txt和我可以使用 它再次作为第一行。
@echo off
echo abc>tf.txt
echo d>>tf.txt
echo e>>tf.txt
rem only sets(and echoes) 1-st row; i want take 1st,2nd,3rd...
rem for example, first echo number of variable
rem then below, in new line, echo char(acters)
setlocal enabledelayedexpansion
for /l %%a in (1,1,5) do (
set /a count=%%a
echo !count!
set /p count=<tf.txt
echo !count!
rem on this point i need to delete 1-st row of tf.txt
rem so i think it will echo the second row if first row
rem doesnt exist at all
pause
)
我做了一些有用的东西。请评论。你喜欢这个吗?
@echo off
rem line taker from txt files
md linetaker
cd linetaker
echo 000000000000000000000000000000000>group.txt
echo 111111111111111111111111111111111>>group.txt
echo 222222222222222222222222222222222>>group.txt
for /f %%x in (group.txt) do (
for /f %%l in ("%%x") do ( echo %%l>>tmp.txt)
move /y tmp.txt "%%x".txt
)
答案 0 :(得分:2)
实际上非常简单。
setlocal enabledelayedexpansion
set num=0
for /f %%i in (tf.txt) do (
set /a num+=1
set line[!num!]=%%i
)
echo line[1] = %line[1]%
echo line[2] = %line[2]%
根据Aacini的评论编辑它使用标准数组符号。