title: Assigning a filename to a variable while traversing through multiple folders
body: <p>I am new to batch programming. I need to traverse through all files in a directory, get the filename, assign it to a variable and then call a subroutine to perform a task. I am stuck in the first task of assigning filename to a variable.
  My code displays the file names correctly here</p>
  
  <pre><code>@echo off
  
  for /R  %%f in (*.*) do (
  echo %%~nf
  )
  </code></pre>
  
  <p>when I assign the name to a variable, only one value gets printed.</p>
  
  <pre><code>@echo off
  
  for /R  %%f in (*.*) do (
  set xFilename=%%~nf
  echo %%xFilename
  )
  </code></pre>
  
  <p>I am missing some basic concept here. Please help.</p>