I have a text file including filename specifications formatted as following, filename-yyyymmdd
source.txt
IMG-20190601
IMG-20190602
IMG-20190603
...
I want to read this file in order to compare the dates with a reference date and do some action depending the result. IMG
is always the same, only the date is changing.
For this purpose I am trying to find the filename date into each line I am reading to compare it with today.
I did not succeed to find the right syntax, I found that extracting a substring can be done with
set SUBSTRING=%VAR:~POSITION,SIZE%
but it is not working with %%variable
type.
Any help is welcome.
My code:
set comparedate=20190702
set /A i=0
for /F "usebackq delims=" %%a in (source.txt) do (
set /A i+=1
rem call echo %%i%%
rem call echo %%a
set datefile=%%a:~4,8 # the line that is not working
if %datefile% geq %comparedate% (goto here) else (goto there)
:here
echo do something
:there
echo do something else
)