title: Batch File Move with Partial File Name to Partial Folder Name String
body: <p>I have a directory full of folders that are named in this manner:</p>
  
  <p>ABC-L2-0001__<strong>2ABC12345-0101</strong>_xxxx</p>
  
  <p>I need to move a lot of files that are named in this manner to the folder that matches the first 9 characters of the files:</p>
  
  <p><strong>2ABC12345-0101</strong>.xyxyxyx.yxyxyxyxy.model</p>
  
  <p>Here's what I'm trying based on reading some older posts of similar requests and it isn't working for me.</p>
  
  <pre><code>:start
  @echo off
  setlocal enableDelayedExpansion
  for /f "tokens=*" %%f in ('dir *.model /b') do (
    set filename=%%f
    set folder8=!filename:~13,9!
    set "targetfolder="
    for /f %%l in ('dir "!folder8!"*.* /a:d /b') do (
       set targetfolder=%%l
    )
  if defined targetfolder move "!filename!" "!targetfolder!"   
  )   
  :end
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>