title: How can I extract the name of a directory from a full path in a batch file?
body: <p>I want to rename files in a directory based on the name of containing directory, like </p>
  
  <pre><code>c:\bin\data01\foo.txt
  </code></pre>
  
  <p>to</p>
  
  <pre><code>c:\bin\data01\data01.txt
  </code></pre>
  
  <p>following the post <a href="https://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd">How to get folder path from file path with CMD</a> .</p>