tags:

views:

27

answers:

1
for /f %%f in ('dir /b C\logs\*.log') do (
 for /f "tokens=2,3,4 " %%i in (\\kobefs01\Administrator$\DKL-Logs\%%f) do (
  if %%i==START echo %%k
 )
)

this script wil brouwse all *.log files searching for START as a second word en then wil echo me the fourth word (a time stamp) but i want that time stamp in a var like this but i doesnt work

for /f %%f in ('dir /b C\logs\*.log') do (
 for /f "tokens=2,3,4 " %%i in (\\kobefs01\Administrator$\DKL-Logs\%%f) do (
  if %%i==START set timestamp=%%k
 )
 echo %timestamp%
)

the %timestamp% var is empty when i echo it? can somebody help me?

Regard Marco

A: 

You are modifying a variable inside a loop, so you have to add this line to the beginnig of your code:

SETLOCAL ENABLEDELAYEDEXPANSION

you also have to change the

echo %timestamp%

to

echo !timestamp!
RoXX
Thanx for your awnser it solved my problem :D
Proxx