How to capture a subdirectory's short subdirectory's name?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
OptimalDesigns
Posts: 6
Joined: 22 Nov 2014 07:56
Location: Medford, Oregon
Contact:

How to capture a subdirectory's short subdirectory's name?

#1 Post by OptimalDesigns » 16 Dec 2015 11:44

In a batch file, I'm trying to capture the short subdirectory name. The long name is in the variable %FCdir%. The following have been tried:
for %%I in ( %FCdir% ) do (set FCdir=%%~sI)
FOR %%A IN ("%FCdir%") DO ECHO %%~sA
FOR /d /r . %%d IN (%FCdir%) DO echo ... %%~sd

For testing, set FCdir=#ReadRite

It seems all answers so far are along this line ... \#ReadR~1\#ReadRite ... a full path. Ideas how to get just '#ReadR~1'?

Thanks,
Phil

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: How to capture a subdirectory's short subdirectory's name?

#2 Post by Squashman » 16 Dec 2015 13:45

Code: Select all

%%~snxI

Post Reply