Computing.Net > Forums > Programming > Batch programming for loop help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch programming for loop help

Reply to Message Icon

Name: Sushmitha
Date: March 5, 2009 at 15:22:57 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: March 5, 2009 at 20:13:32 Pacific
Reply:

for /d %%a in ("%SOURCEFLOODPATH%\*") do echo %%~na


0

Response Number 2
Name: Sushmitha
Date: March 9, 2009 at 09:27:29 Pacific
Reply:

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?


0

Response Number 3
Name: Taurus666
Date: May 29, 2009 at 00:01:46 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch programming for loop help

Batch Programming for XP help www.computing.net/answers/programming/batch-programming-for-xp-help/13573.html

Batch file nested FOR loops help www.computing.net/answers/programming/batch-file-nested-for-loops-help/15196.html

Batch file FOR LOOP www.computing.net/answers/programming/batch-file-for-loop/11504.html