• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

There must be a better way to write this batch file?

TechnoPro

Golden Member
I wrote a simple script that we use to detect the presence of certain directories and files and then perform certain tasks accordingly. By virtue of the mixed computer setup in the office, this directory can exist on any drive letter from C-Z. So this script manually checks each one.

IF EXIST "C:\%SPECIAL_PATH%" (SET LOCAL_DRIVE=C& GOTO CREATE) ELSE (ECHO.)

IF EXIST "D:\%SPECIAL_PATH%" (SET LOCAL_DRIVE=D& GOTO CREATE) ELSE (ECHO.)

IF EXIST "E:\%SPECIAL_PATH%" (SET LOCAL_DRIVE=E& GOTO CREATE) ELSE (ECHO.)

...

IF EXIST "Z:\%SPECIAL_PATH%" (SET LOCAL_DRIVE=Z& GOTO CREATE) ELSE (ECHO.)

Is there a cleaner way of writing this out? Like somehow setting a range of values b-z? I'm very grateful for any suggestions.
 
You didn't specify which OS, but on Windows XP (2K also) you should be able to build something from:

for %x in (a,b,c,d,e,f,g,h) do echo %x

In an actual batch file the %x should be %%x

Bill
 
Originally posted by: bsobel
You didn't specify which OS, but on Windows XP (2K also) you should be able to build something from:

for %x in (a,b,c,d,e,f,g,h) do echo %x

In an actual batch file the %x should be %%x

Bill

What a lifesaver you are, thank you! That works like a charm! Drinks are on me if you're ever in my neck of the woods.
 
Back
Top