Batch file colon problem

April 14, 2017 at 22:00:34
Specs: Windows 7
Hey all,

I hope this will be my last problem concerning batch, since it is related to my last Question.

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:

(for /F "tokens=1,2 delims=:<>" %%a, in ('findstr "xxxxxxxxxxxName=\"PHIL\" XXXXXXXX=\"Executive13\"" *.xml') do (
set "list=%%b"
for /F "delims=" %%c in (^"!list: ^=^
% Do NOT remove this line %
!^") do set %%c
if "!xxxxxxxxxxxName!+!XXXXXXXX!" 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" XXXXXXXXXXName="PHIL" testVersion="13" lockTime="2017-04-11T11:20:05"
<result testStepName="locating" sequenceNrResult="1" testStepResult="OK">

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).

See More: Batch file colon problem

Report •

April 19, 2017 at 07:52:44
I may take a look at your problem tommorow if i got the time, for now i give you a tip:

set variable=test:123
echo %variable::=%

output: test123

but since you're using a for loop this might not be helpfull :/

Simple solutions are often the best

Report •

April 21, 2017 at 20:39:36
Hey Hidde663

I almost gave up on this question ! Thanks for your help.

Unfortunately it didnt work for: :(

set variable=test:123
echo %variable::=%

Report •
Related Solutions

Ask Question