I am looking for shortest solution for the following problem:
I would like to learn the last directory entry in current path, so for C:\Temp\Local the function should return Local
I have come to the following solution but I wonder, if there is more shorter/optimal one:
@echo off
set dir=%CD%
:repeat
for /F "tokens=1,* delims=\" %%a in ("%dir%") do (
if "%%b" == "" goto :end
set dir=%%b
)
goto :repeat
:end
echo %dir%
1 Answer