title: batch script moving multiple file extensions to sub folder passing parameters to a single subroutine
body: <p>So, I am trying to code a batch script operation that handles moving certain types of file extensions (photos = .jpg, .png etc) to their respective sub directory. </p>
  
  <p>The problem I am in counter is when I go to run the loop doesn't stop and I can't track if certain types are being looped through.</p>
  
  <p>Is there a way of doing this operation within a single subroutine? Or a better way? Also, if you can leave helpful links as I really would like to understand what I am coding more thoroughly.</p>
  
  <p>I am running Windows 8.1</p>
  
  <pre><code>    :cleanup
  set Fdocs=%CD%\1_docs
  set Fphotos=%CD%\2_photos
  set Fdesigns=%CD%\3_designs
  set Freviews=%CD%\4_reviews
  set Ffinal=%CD%\5_final
  set $ext=
  set action=Cleaning
  
  :: Create a subroutine function loop : FOR , go through array file extentions and move to destination
  :: FOR /F
  :fMover
  for %%a in (%1) do move "%CD%\*%%a" "%CD%\%2"
  echo %%a
  timeout 1 &gt;nul
  
  :: CLEAN :: documents
  set $ext=.txt .doc .docx .xls .csv .ppt .pptx
  call :fMover %$ext% %Fdocs%
  cls
  echo %action% project folder.
  
  
  :: CLEAN :: images
  set $ext=.jpg .png .tiff .raw .nef .crw .dng
  :: for %%a in (%$ext%) do move "%CD%\*%%a" "%CD%\%Fphotos%"
  call :fMover %$ext% %Fphotos%
  cls
  echo %action% project folder..
  timeout 1 &gt;nul
  
  
  :: CLEAN :: designs
  set $ext=.psd .psb
  call :fMover %$ext% %Fdesigns%
  ::for %%a in (%$ext%) do move "%CD%\*%%a" "%CD%\%Fdesigns%\2_psd"
  set $ext=.ai .svg .svgz .esp
  call :fMover %$ext% %Fdesigns%
  ::for %%a in (%$ext%) do move "%CD%\*%%a" "%CD%\%Fdesigns%\1_ai"
  set %ext=.indd .idml 
  call :fMover %$ext% %Fdesigns%
  ::for %%a in (%$ext%) do move "%CD%\*%%a" "%CD%\%Fdesigns%\3_indd"
  cls
  echo %action% project folder...
  timeout 1 &gt;nul
  
  
  cls
  echo done.
  timeout 2 &gt;nul
  </code></pre>