date - bat file read in file -


i have text file datefile.txt contains

10-06-2013

and tried read using following bat file:

@echo off setlocal disabledelayedexpansion /f "usebackq delims=" %%a in (`"findstr /n ^^ datefile.txt"`) (     set "var=%%a"     setlocal enabledelayedexpansion     set "var=!var:*:=!"     echo(!var!     endlocal ) echo %var% 

the output got these:

10/06/2013 1:10/06/2013 

how come %var% different above one. or how remove "1:" in %var%?

thanks.

you got type of output, first line written echo(!var!.
second line echo %var%, in second case variable doesn't contain same.

this because setlocal/endlocal block inside loop.

in case can remove block, date doesn't contains exclamation marks nor carets.

@echo off setlocal enabledelayedexpansion /f "usebackq delims=" %%a in (`"findstr /n ^^ datefile.txt"`) (     set "var=%%a"     set "var=!var:*:=!"     echo(!var! ) echo %var% 

and if file contains 1 line, solution simplified by

<datefile.tx set /p var= echo %var% 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -