In both cases the directory contains three files named test1.txt, test2.txt, test3.txt
Can someone explain why this works:
echo off
set CP=
for %%f in (*.txt) do (
call :concat %%f
)
echo %CP%
:concat
set CP=%CP%;%1
output:
C:\test>test
C:\test>echo off
;test1.txt;test2.txt;test3.txt
C:\test>
But this does not:
echo off
set CP=
for %%f in (*.txt) do (
set CP=set CP=%CP%;%%f
)
echo %CP%
output:
C:\test>test
C:\test>echo off
;test3.txt
C:\test>