setting variable within for loop
Posted: 18 Mar 2011 04:38
Hi,
My problem is as follows.
I have 2 directories software_test_R1.1 and software_test_R1.2 contained with a parent directory called test
My code is as follows
@echo off
for /f "tokens=* delims=" %%X in ('dir /ad /b') do (
for /f "tokens=3 delims=_" %%A IN ("%%X") do (
echo %%A
set version=%%A
echo %version%
)
)
I expected that within second for loop that echo %%A would give me the same value as echo %version%
What i get is
software_test_R1.1
R1.1
R1.2
software_test_R1.2
R1.2
R1.2
Does anyone know the fix for this ?
Thanks
My problem is as follows.
I have 2 directories software_test_R1.1 and software_test_R1.2 contained with a parent directory called test
My code is as follows
@echo off
for /f "tokens=* delims=" %%X in ('dir /ad /b') do (
for /f "tokens=3 delims=_" %%A IN ("%%X") do (
echo %%A
set version=%%A
echo %version%
)
)
I expected that within second for loop that echo %%A would give me the same value as echo %version%
What i get is
software_test_R1.1
R1.1
R1.2
software_test_R1.2
R1.2
R1.2
Does anyone know the fix for this ?
Thanks