I'm trying to get a user to enter a folder name from those listed in a particular directory. The following gives me the list but contains the full path which is likely to confuse the user. My string %officeL% refers to the path location e.g. c:\folder1\folder2\
for /d %%X in (%officeL%*) do echo %%X
Ideally I'd like to just get a simple list of just the folders in the final location specified in my string e.g. client1, client2, client3...
You could use batch parameter modifiers:
for /d %%X in (%officeL%*) do echo %%~nX
See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true or
for more information.
Following will work for you
@Echo OFF FOR /F %%G IN ('DIR /b %officeL%') DO CALL :Folders "%%G" EXIT /b :Folders SET str1=%~1 Echo %str1%