set Name=Test_
Test_052202.log
Test_052202a.log
Test_052202b.log
Test_052202c.log
The final log name would be stored in some env var like LogName
I hope I've explained this well and not just toaly confused the issue
Thanks
Eric
OS: Win2k & WinXP pro
--
...
...
...This Post Has Been Tested and is Anthrax Free...
...
...
ps: Thanks! to the poster who posted that neat for loop at the top. So nice!
@ECHO OFF
set TestName=NewTest
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set DayOfWeek=%%i
set Month=%%j
set Day=%%k
set Year=%%l
set Date=%%i %%j/%%k/%%l
)
ECHO Date is %Date%
ECHO Day of Week is "%DayOfWeek%", Month is "%Month%"
ECHO Day is "%Day%", Year is "%Year%"
set LogName=%TestName%_%Year%%Month%%Day%.lox
rem if NOT EXIST %LogName goto GotIt
for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
set LogName=%TestName%_%Year%%Month%%Day%%%i.loy
Echo %LogName%
rem if NOT EXIST %LogName goto GotIt
)
:GotIt
--
...
...
...This Post Has Been Tested and is Anthrax Free...
...
...
"Eric B." <NoS...@NoSpammers.com> wrote in message
news:UZNJ8.67292$ux5....@rwcrnsc51.ops.asp.att.net...
You have encountered the current environment variable expansion
problem where %logname% is expanded to its current value BEFORE the
FOR loop is executed. In fact the 2nd line is being executed correctly
but you're just not seeing those results. When 'echo %logname%' is
executed, %logname% has already been replaced with the value it had
before the FOR command commenced. See SET /? for more information.
There are 2 ways to fix this. In W2k/XP you can enable delayed
variable expansion by adding the line 'setlocal
enabledelayedexpansion' near the start of the file and replace 'echo
%logname%' with 'echo !logname!'. That is, surround the variable with
"!" instead of "%".
The other method is to CALL echo with an extra level of % expansion.
Replace 'echo %logname% with 'call echo %%logname%%'. This will work
in NT as well as W2k/XP.
Garry
:GotIt
Echo Log: %LogName%
The info you posted is very helpfull, i am examining ways to
simplify what i already have by using the info you posted.
Thanks Again
Eric
--
...
...
...This Post Has Been Tested and is Anthrax Free...
...
...
"Garry Deane" <garrydeane_at_yahoo.com.au> wrote in message
news:3cfacab6...@192.168.0.2...