Two options based on what you have:

set FOLDER=%%a
set FIRSTCHAR=!FOLDER:~0,1!
if /i *!FIRSTCHAR!*==A goto :MAPA
if /i *!FIRSTCHAR!*==B goto :MAPB
if /i *!FIRSTCHAR!*==C goto :MAPC
GOTO :END


Or....

set FOLDER=%%a
set FIRSTCHAR=!FOLDER:~0,1!
GOTO MAP*!FIRSTCHAR!*

GOTO :END



Then continue on with the rest of what you have...

(I would recommend surrounding your comparisons in quotes, just to avoid bad
input situations:  if /i "*!FIRSTCHAR!"*=="A" goto :MAPA)

Execution can be a bit interesting when the whole large block is in
parentheses, so make sure you don't have other random parentheses laying
about, or expand the whole block of execution into its own subroutine and
CALL it instead.   What you have *should* work.


* *

*ASB* *http://XeeMe.com/AndrewBaker* *Harnessing the Advantages of
Technology for the SMB market…

*



On Tue, Aug 16, 2011 at 10:48 AM, m b <[email protected]> wrote:

> Apologies in advance, I did try googling, not finding exactly what I need.
> I do this so infrequently now, I can't recall what I need when I need it.
>
> I need to read a text file containing a list of directories, and for each
> directory, I need to pull the first character of the directory name & then
> take action based on that character.  Ultimately, I'm needing to create a
> bunch of DFS links, and our folder's actual home locations are in different
> places depending on their alphabetical order.  I can handle the dfscmd part,
> I just can't come up with something to get me rolling through the list.
>
> Here's what I've been wrestling with so far.  If I'm way off track, I'm
> humble enough to accept a complete overhaul, and even some ridicule.
> 'directorylist.txt' is a list of all the folders on our current DFS that we
> intend to replace.
>
> rem setLocal EnableDelayedExpansion
> @echo off
>
> for /f "Tokens=*" %%a in (c:\tasks\directorylist.txt) do (
>  set FOLDER=%%a
>  set FIRSTCHAR=!FOLDER:~0,1!
>  if FIRSTCHAR==A goto MAPA
>  if FIRSTCHAR==B goto MAPB
>  if FIRSTCHAR==C goto MAPC
>
> :MAPA
>  set MAPPATH=client2\client_a$
> rem insert dfs link creation for folders beginning with 'a'
> goto END
>
> :MAPB
>  set MAPPATH=client1\client_b$
> rem insert dfs link creation for folders beginning with 'b'
> goto END
>
> :MAPC
>  set MAPPATH=client1\client_c$
> rem insert dfs link creation for folders beginning with 'c'
> goto END
>
> rem etc etc on through 'Z'
>
> :END
> )
>
>
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to