Get foldername without path using dir in cmd

Viewed 10021

By using:

dir /s /b /o:n /a:d > foldername.txt

I get the following output:

D:\Project\Java\MyName
D:\Project\Java\Object

But I want the output to look like this:

MyName
Object  

The output have to be folder names without their paths?

2 Answers

just use

DIR D:\Project\Java\ /b

the result will be just like what you want

Related