Reputation: 39
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...
Upvotes: 3
Views: 5257
Reputation: 837
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 /?
for more information.
Upvotes: 4
Reputation: 484
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%
Upvotes: 1