title: How to get the maximum directory depth of the current working directory
body: <p>I'm trying myself at <a href="https://en.wikipedia.org/wiki/Batch_file" rel="nofollow">Windows batch programming</a> at the moment. So far so good, and I could nicely figure out how to delete empty directories and files that were older than x days. The problem is that, if I start the deleting of the empty directories, and we assume that the process only runs once, there always will be new empty folders left on the condition that the current working directory has such a structure:</p>
  
  <pre><code>Empty Folder
  
       Empty Folder
  
            Empty Folder
  
                 Empty Folder
  
  Folder
  
  Folder
  
  ...
  </code></pre>
  
  <p>In this case, only the last empty folder will be deleted, but then there is again an empty folder. For this I need to calculate the maximum directory depth (in that case 3 --> because of the three sub-directory structure). If I would have had this depth I could run the deleting process x (dir-depth) times. How I can get the directory depth in Windows batch programming?</p>