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.
Based off the solution @ How to concatenate strings in a Windows batch file? I managed to come up with the below batch file:
@echo off
set myvar='
for /f %%i in ('dir /b /o:n /ad') DO call :concat %%i
echo %myvar% >>test.txt
goto :eof
:concat
set myvar=%myvar%%1',
goto :eof
which produces a .txt file containing the output:
'folder_1', folder2', folder',
How can I get the output to look more like this:
'folder_1',
'folder2',
'folder 3'
--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.