title: Batch Script to rename files from folder name; issue with "-"
body: <p>Been using this script for years that I found from here for renaming movie filenames from parent foldernames:</p>
  <pre><code>@echo off
  for /r /d %%x in (*) do (
   pushd &quot;%%x&quot;
   echo %%x
   for /F %%i in (&quot;%%x&quot;) do (
    ren *.mkv &quot;%%~ni.mkv&quot; 2&gt; NUL
    ren *.avi &quot;%%~ni.avi&quot; 2&gt; NUL
    ren *.mp4 &quot;%%~ni.mp4&quot; 2&gt; NUL
   )
   popd
  )
  </code></pre>
  <p>So the only issue that I'm having is the parent folder looks like this:
  MovieFolder-xyz</p>
  <p>Running the script, the filename will be:
  MovieFolder.mp4</p>
  <p>the issue here is the &quot;-xyz&quot; gets omitted and I'm too simple minded to figure out how to fix this script so that I don't have to manually rename all the files.  Tia!</p>