title: Batch file moving to subfolders
body: <p>I have lots of folders including images in it. Example:</p>
  
  <pre><code>C:\U2090_08 
  C:\U2111_08
  C:\U2024_03 
  C:\U2024_08 
  C:\U2049_15
  C:\U2049_35
  </code></pre>
  
  <p>There are 3-4 jpg files in every folder. I want to create a sub-folder called "kck" in every folder and move jpg files to this subfolder.</p>
  
  <p>Example:</p>
  
  <p>Before process:</p>
  
  <pre><code>C:\U2049_35\1.jpg
  C:\U2049_35\2.jpg
  C:\U2049_35\3.jpg
  </code></pre>
  
  <p>After process:</p>
  
  <pre><code>C:\U2049_35\kck\1.jpg
  C:\U2049_35\kck\2.jpg
  C:\U2049_35\kck\3.jpg
  </code></pre>
  
  <p>Here is what I am trying:</p>
  
  <pre><code>@echo off
  cd %USERPROFILE%\Desktop
  
  :: Sorting images in '\Desktop\images'
  for /f "delims=" %%I in (' dir /b "%USERPROFILE%\Desktop\images\*.jpg" ') do (
      if not exist "%USERPROFILE%\Desktop\images\%%~nI\kck" ( md "%USERPROFILE%\Desktop\images\%%~nI\kck" )
      move "%USERPROFILE%\Desktop\images\%%~I" "%USERPROFILE%\Desktop\images\%%~nI\kck\"
  )
  exit
  </code></pre>
  
  <p>Folders including jpg files in a folder called images on desktop.</p>
  
  <p>Any ideas ?</p>