Get foldername without path using dir in cmd
<p>By using:</p>

<pre><code>dir /s /b /o:n /a:d &gt; foldername.txt
</code></pre>

<p>I get the following output:</p>

<pre><code>D:\Project\Java\MyName
D:\Project\Java\Object
</code></pre>

<p>But I want the output to look like this:</p>

<pre><code>MyName
Object  
</code></pre>

<p>The output have to be folder names without their paths?</p>