I'm having a problem with my batch script. I am trying to extract the time & date but due to the colon it gives me an incomplete date & time.
Here's the script:
Code: Select all
(for /F "tokens=1,2 delims=:<>" %%a, in ('findstr "Name=\"PHIL\" currentState=\"Executive13\"" *.xml') do (
set "list=%%b"
for /F "delims=" %%c in (^"!list: ^=^
% Do NOT remove this line %
!^") do set %%c
if "!Name!+!currentState!" equ ""PHIL"+"Executive13"" (
echo File: "%%a", date=%%~ta", testDuration=!testDuration!, holidayCount=!holidayCount!, lockTime=!lockTime!"
)
)) > Outputfile.txt
start notepad outputfile.txt
The time is dated in XML files as:(extracted from"lockTime"):
<testInfo testDuration="57" holidayCount="0" completedtask="12" currentState="Executive13" Name="PHIL" testVersion="13" lockTime="2017-04-11T11:20:05"
<result testStepName="locating" sequenceNrResult="1" testStepResult="OK">
etc.
</testInfo>
</testresult>
How do I fix this problem with the colon with batch?
Output file always looks like this:
lockTime="2017-04-11T11" ( normally it should display :"2017-04-11T11:20:05" )
If I remove : from first for /f statement's delims= clause. it will fix the "lock time". BUT it won't show me the modified Date then anymore (date=%%~ta).
Thank you for reading and help in advance !