Oh, thank you very much! Fantastic.
I kind of see what it does. With 20-20 hindsight, some of it almost appears obvious. Isn't that always the way?
To me, it seems that the parsing part of the FOR "engine" only sees it as a string. That means it does not know if "d" is a file or a folder, so one can simply extract a folder name by using file syntax. It would be the same if the folder or file name was "d.x". (It has an extension.)
The part I don't quite get in this is the "\." suffix. Once you got me on the right track, I tried all these "in (...)" combos and got the same results for all:
for /f "delims=" %%G in ("%cd%\.") do set "folder=%%~nxG"
echo.
echo %%cd%%\. %folder%
echo.
for /f "delims=" %%G in ("%cd%.") do set "folder=%%~nxG"
echo.
echo %%cd%%. %folder%
echo.
for /f "delims=" %%G in ("%cd%") do set "folder=%%~nxG"
echo.
The syntax for all of the above work whether the directory is "d" or "d.x"
For me trying to understand the command line, I ask what does the "\." suffix do?
I also noticed I can eliminate "delims=" and get the same results for that path. But it breaks if there are spaces (like C:\a\b\c c\d), so I am I right that "delims=" sets the delimiter to "nothing?" (Meaning, there are no delimiters, take the whole string.)
Thanks again.