title: How do I loop throw files names in a direcorty and then pull their names to get substirng values
body: <p>So I am looping through files within a directory and want to get the filename and as i get the filename I will want to break it down with delim because I will be getting the first portion of the name before the first underscore. Many examples use this for /f loo[ with token/delim settings but when i run this code it says for the echo of i as: !var! and then when I get ride of the &quot;&quot; i get The system cannot find the file !var!</p>
  <p>I am guessing my syntax is incorrect and maybe even my approach of my script is as well. Any suggestions?</p>
  <pre><code>@ECHO OFF
  
  for /r %%a in (*.pdf) do (
      echo %%~nxa
      set var=%%~nxa
      
      for /F &quot;tokens=1-2 delims=_&quot; %%i in (&quot;!var!&quot;) do (
          echo %%i %%j
      )
  
  )
  
  PAUSE
  </code></pre>