title: Get output of batch script into the correct subdir with /R flag
body: <p>I'm currently facing the problem that I need process files in every sub-directory, I'm using a for loop like this one:</p>
  
  <pre><code>for /R %%x in (*.dat) do tool.exe -c -f -e "%%x"
  </code></pre>
  
  <p>Now it does process everything but the tool outputs a file and that file always lands in the directory where the batch script got launched in and not in the directory where the original file was located.
  I tried a quite a few approaches like using %CD% as the output directory option for the tool but it looks like the tool didn't like that very much and just gave errors.</p>
  
  <p>I'm looking for a general solution as I had this problem with quite a few CLI tools now.</p>