Batch programming for loop help

March 5, 2009 at 15:22:57
Specs: Windows XP
I have DE, TX, NC folders in C:\Program Files\RMS\RiskLink\Data\USData\Flood\HiresTest

SET SOURCEFLOODPATH=C:\Program Files\RMS\RiskLink\Data\USData\Flood\HiresTest
FOR /D %%a in ("%SOURCEFLOODPATH%\*.*") DO (
SET FOLDERNAME=%%a
SET FOLDERNAME

SET TMPSTATE=%FOLDERNAME:~-2%
SET TMPSTATE
)

using the the above code i have expected the TMPSTATE to be DE, TX and NC. But it is always showing ~-2. Please help me to get the expected result


See More: Batch programming for loop help

Report •


#1
March 5, 2009 at 20:13:32
for /d %%a in ("%SOURCEFLOODPATH%\*") do echo %%~na

Report •

#2
March 9, 2009 at 09:27:29
Thanks Reno,

I need to change a for loop which has to find all the shape files starting with the letter f. How can i achieve this?


Report •

#3
May 29, 2009 at 00:01:46
U meaning like this?

@echo off
for /f "tokens=*" %%i in ('Dir /a /b /s "%~dp0\*"') do (
echo Name =%%~ni
echo type =%%~xi
echo ------------------------------------
)
pause


Report •

Related Solutions


Ask Question