How can I read two consecutive lines of a text file and save them as temporary variables

I have files with ID, modeland date. files have a format similar to 10000_9999-99_10-01-2011.zip(where 10000is ID, 9999-99is model, and, of course, 10-01-2011is date).

I would like to modify datethese files, but keep the interval between sessions with the same ID. For example, if 2 sessions had dates 1/1/2011and 2/1/2011, and I wanted to update the last date of the session to 8/1/2012, the first session would have a date 7/1/2012.

Currently my code is as follows:

@echo off
setlocal enabledelayedexpansion
del filedates.txt
FOR /F "tokens=1,2,3,4,5 delims=_" %%a in (filenames.txt) do @echo %%c >>filedates.txt
FOR /F "tokens=1,2,3 delims=-" %%a in (filedates.txt) do (
  echo %%a%%b
)

The result is similar to this (YearMonth):

201107
201109
201204
etc..

filedates.txt, , . , , , , .

+5
1

- for /f "" . :

@echo off
setlocal enabledelayedexpansion
set evenflag=1
for /f "tokens=*" %%x in (filedates.txt) do set x1=!x2! && set x2=%%x && (
set /a evenflag^^=1 && if !evenflag!==1 (
    rem Do something with !x1! and !x2!
))

evenflag , , (1 , 0 ). x1 x2 .

+2

All Articles