setlocal enabledelayedexpansion
for /f "delims=" %%a in (%TempFile2%) do (
set a=%%a
set a=!a: =!
echo !a! >>%DataFile%
)
I understand that code looks for every “empty space” in tempfile2 data and sets it. What does this line mean ?
set a=!a: =!
Thanks
It’s a basic pattern match and replace.
Here’s the help from
set /?:The additional twist in your example is that the ‘delayed expansion’ syntax is being used, which uses the
!character as the environment variable expansion character instead of%.So the command
set a=!a: =!is removing all space characters from the contents of the variablea.Delayed expansion is needed (or at least makes something like this a bit easier) because of the way cmd.exe normally expands (then using the
%delimiter) the entire set of commands in the block enclosed by parens before executing any part of it.