title: batch dir output including concatenation to a txt file
body: <p>I have a directory which I'd like to output the subfolder names (ex: "folder_1" "folder2" "folder 3") enclosed in single quotes and followed by a comma each, into a txt file. </p>
  
  <p>Based off the solution @ <a href="https://stackoverflow.com/q/2027070/4534651">How to concatenate strings in a Windows batch file?</a> I managed to come up with the below batch file:</p>
  
  <pre><code>@echo off  
  set myvar='  
  for /f %%i in ('dir /b /o:n /ad') DO  call :concat %%i  
  echo %myvar% &gt;&gt;test.txt  
  goto :eof   
  
  :concat  
  set myvar=%myvar%%1',   
  goto :eof
  </code></pre>
  
  <p>which produces a .txt file containing the output:</p>
  
  <pre><code>'folder_1', folder2', folder',  
  </code></pre>
  
  <p>How can I get the output to look more like this:</p>
  
  <pre><code>'folder_1',  
  'folder2',  
  'folder 3'
  </code></pre>
  
  <p>--Need each subfolder name (incl space/s) enclosed in single quotes followed by comma. If possible, I'd also like each folder on a separate line and no comma on the very last folder.</p>