title: Batch: Save directory listing into list-variable
body: <p>I want to take a file from a source directory (<code>C:\Users\Desktop\Source\Test.xlsx</code>) and want to replicate it to several folders, all having the same structure. So I have to change just one folder name. All done via one batch file and just one log-file which is created afterwards.</p>
  
  <p>To have dynamically expansion of my batch-procedure here, I want to do a filtering of the elements of the root folder (<code>C:\Users\Desktop\Replica\</code>), which shows me the childs (<code>one</code> <code>two</code> <code>three</code> <code>four</code> <code>five</code>) where the file needs to be copied at inside a <code>testfolder</code>. There I have done the following at the moment, which is static:</p>
  
  <pre><code>set "list=one two three four five"
  (
   for %%i in (%list%) do (
    xcopy "C:\Users\Desktop\Source\Test.xlsx" "C:\Users\Desktop\Replica\%%i\testfolder" /Y  
   echo(%%i
   echo(
  )
  )&gt;copylog.txt
  </code></pre>
  
  <p>So, my question is basically who I do the listing of just the folders under "replica" and put those inside a list variable I can use in the code as already written. I only found sources where these are just saved within a separate .txt-file, but I just want to keep it inside the batch. </p>
  
  <p>Any guesses on this one?</p>
  
  <p>By the way: I experienced by saving a path just as a variable, I couldn't execute <code>xcopy %source% %target%</code> (even when having "<code>%source%</code>" or <code>source = "Path"</code>). What is the problem here?</p>