title: Batch: Parsing out file path from dynamic array
body: <p>Looking to parse out the path from a specific point &amp; then use that to populate the dynamic array.</p>
  
  <p>Example:</p>
  
  <pre><code>Folder tree:
  C:\Main\folder1
  C:\Main\folder2\folder2-1
  C:\Main\folder3\folder3-1\folder3-2
  
  Desired result:
  Array[1]=folder1
  Array[2]=folder2
  Array[3]=folder2\folder2-1
  Array[4]=folder3
  Array[5]=folder3\folder3-1\
  Array[6]=folder3\folder3-1\folder3-2
  </code></pre>
  
  <p>This is the working code below which returns fine but in full paths:</p>
  
  <pre><code>@echo off
  setlocal EnableDelayedExpansion
  SET folders=C:\Main
  
  rem Populate the array with existent files in folder
  set i=0
  for /r "%folders%" /d %%a in (*) do (
     set /A i+=1
     set list[!i!]=%%a
  )
  set foldnum=%i%
  
  rem Display array elements
  for /L %%i in (1,1,%foldnum%) do (SET array[%%i]=!list[%%i]!)
  
  for /F "tokens=2 delims==" %%f in ('set array[') do echo %%f
  </code></pre>