I would like to put a text on its contents for such a form:
25
69
89
99
120
Processed into the following forms:
25 69
69 89
89 99
99 120
This means that the next line of numbers is copied to the back of the previous line and separated by a space. Do not know DOS can do?
Copy Code code as follows:
@echo off
:: Copy the next line of numbers to the back of the previous line, separated by a space
Setlocal enabledelayedexpansion
for/f%%i in (test.txt) do (
set/a count+=1
Set first=!second!
Set second=%%i
If!count! GTR 1 echo!first!!second!
)
Pause
The general idea is to extract the number of each row, give the variable second, and at the same time, use the variable first to receive the variable second the previous value, so that second takes the number of the current row, and first gets the contents of the previous line. If you use if to determine whether the value of Count is 1, because when Count is 1, the value is not yet taken.