title: In a batch file, how do I separate a file name and a file extention from a file path?
body: <p>I have a batch file that accepts a file path. I then need to isolate the file name and the file extention separately. For example, if my file path is "\svr-01\My Docs\My Spreadsheet.xls" then I need two separate variables; one containing 'My SpreadSheet" and one containing ".xls".</p>
  
  <p>Heres what i have so far. I have been able to seperate the filename and extention from the path:</p>
  
  <pre><code>set FILEPATH=\\SVR-01\My Docs\My Spreadsheet.xls
  for /F "delims=" %%A in ("%FILEPATH%") do set "FILENAME=%%~nxA"
  echo.%FILENAME%
  </code></pre>
  
  <p>How do i then separate the file name and the extention from this variable?</p>