For what I please need help with is getting the 1st line of text from a file that has the following values:
text file (Login.txt) contents:
<unknown time> TT\1stName2.LastName
12/27/2013 1:52:50 PM TT\1stName.LastName
I say about 50% of the time the file, Login.txt, shows <unknown time> instead of date and time stamp, as the 2nd line in the text file shows, of last logged in.
My code here reads the text file, Login.txt, but completely ignores the 1st line of text due to the greater than and less than symbols <,>. When the <,> symbols are present, the output of the batch script always outputs the 2nd line.
Whether the 1st line shows the standard date and time or the <,> symbols, I need to preserve what is shown on the 1st line.
I could use:
Code: Select all
set /p line1=< c:\temp1\Login.txt
but that doesn't interpret the <,> characters when those characters show up and only works when the 1st line shows a standard date and time.
If I can get assistance on this, v/r Booga73
Code: Select all
setlocal
for /f "usebackq tokens=1-10 delims=*" %%a in ("c:\temp1\Login.txt") do (
set atrib1=%%a
set atrib2=%%b
set atrib3=%%c
set atrib4=%%d
set atrib5=%%e
set atrib6=%%f
set atrib7=%%g
set atrib8=%%h
set atrib9=%%i
set atrib10=%%j
)
set EndUser1=%atrib1% %atrib2% %atrib3% %atrib4% %atrib5% %atrib6% %atrib7% %atrib8% %atrib9% %atrib10%
echo My User: %EndUser1%
pause
1st Example of output, this is an example of my script output when the first line of text doesn't have the <,> characters:
My User: 12/27/2013 1:52:50 PM TT\1stName.LastName
Press any key to continue . . .
2nd Example of intended output if <,> characters are found in the first line of text:
My User: <unknown time> TT\1stName2.LastName
Press any key to continue . . .