title: Organize files with batch script
body: <p>I need to somehow copy all files from source folder(including subfolders) to destination folder keeping the subfolders name as a file name.</p>
  
  <p>Using batch file on windows.</p>
  
  <p>Example:</p>
  
  <pre><code>sourceFolder\packed1.bin
  sourceFolder\data1\packed1.bin
  sourceFolder\data1\packed2.bin
  sourceFolder\data1\zz\packed1.bin
  sourceFolder\data1\aa\packed1.bin
  sourceFolder\data1\aa\22\packed1.bin
  </code></pre>
  
  <p>should become...</p>
  
  <pre><code>destinationFolder\packed1.bin
  destinationFolder\data1-packed1.bin
  destinationFolder\data1-packed2.bin
  destinationFolder\data1-zz-packed1.bin
  destinationFolder\data1-aa-packed1.bin
  destinationFolder\data1-aa-22-packed1.bin
  </code></pre>
  
  <p>I tried using <code>goto</code> but I cannot keep the track of which directory I am in and then return to it.</p>
  
  <pre><code>@echo off
  setlocal EnableDelayedExpansion
  
  set mypath=%cd%
  set "_orig=%mypath%\datafolder"
  set "_origCurr=%_orig%"
  set "_dest=%mypath%\untree\"
  
  set procDirs
  set /a procDirsL=0
  set currDirS=""
  set /a isProc=0
  
  :gofolders
  for /d %%D in ("%_dest%\*.*") do (
  set currDirS=%currDirS%\%%D
  set procDirs[!procDirsL!]
  
  set /a procDirsL=!procDirsL!+1
  
  
  goto gofolders
  )
  
  :dofiles
  for /f %%F in ("%_dest%\*.*") do (
  
  )
  goto gofolders
  </code></pre>