Given the following directory
D:\>dir D:\test1 /b
.dir1dot
.dir2dot
dir1
dir2
file1.txt
file2.txt
I want to iterate through all the directories from a given directory in Windows 10. Therefore I've built the following command
D:\>for /d %i in (D:\test1\*) do @echo %i
D:\test1\.dir1dot
D:\test1\.dir2dot
D:\test1\dir1
D:\test1\dir2
Now I want to obtain the names of the directories. That is:
.dir1dot
.dir2dot
dir1
dir2
I have tried executing the following but this is what happens:
D:\> for /d %i in (D:\test1\*) do @echo %~ni
ECHO is on.
ECHO is on.
dir1
dir2
Thus, the question is How can I only display the names of the directories from a given directory?