title: Batch Script to Find a Folder inside Sub Folders and get Path
body: <p>I'm trying to get path of a directory containing <strong>.snapshot</strong> folder. .snapshot should be searched in all parent and sub-directories.</p>
  
  <p>I've a directory structure resembling following tree command output (only more complex, deployment deals a huge NAS drive)</p>
  
  <p><a href="https://i.stack.imgur.com/DXBWZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DXBWZ.png" alt="enter image description here"></a></p>
  
  <p>My script, as below, so far lists only one out of potentially 100s of directories containing .snapshot</p>
  
  <pre><code>set Dir=C:\Vol
  cd %Dir%
  for /d  /r "%Dir%" %%a in (*) do if /i "%%~nxa"==".snapshot" set "folderpath=%%a"
  echo "%folderpath%"
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>C:\Vol\xnd76540\u44753\mike.smith\.snapshot
  </code></pre>
  
  <p>My Question</p>
  
  <p>How can I check all sub-directories of a folder for .snapshot, come back to the parent and follow another path for again searching .snapshot in other set of sub directories and so on?
  Performance tips appreciated.</p>
  
  <p>Couldn't find a more relevant code snippet.</p>