title: Correct syntax for variable modifiers when using EnableDelayedExpansion
body: <p>I want to be able to do %~p to only see the path of the file. But I cant get the correct syntax when using it in a loop (With EnableDelayedExpansion)</p>
  
  <p>Here's my code:</p>
  
  <pre><code>@echo off
  set "dir1=%TMP%\opt"
  set "dir2=c:\opt"
  set "empty="
  
  setlocal EnableDelayedExpansion
  for /f %%F in ('dir  /a:-d /s /b /r "%dir1%"') do (
    set "file_path=%%F"
    set "file_name=%%~nF"
    set "new_path=!file_path:%dir1%=%dir2%!"
    set "new_path=!new_path:!file_name!=%empty%" //This command is problematic
    echo !new_path!
  )
  endlocal
  </code></pre>
  
  <p>Any way for me to do this?</p>