I am writing a file to remove spaces from filenames in a folder and then put the result in a .txt file. I just get a result of \"Echo is on.\" over and over.
.txt
Removing all spaces (not just leading and trailing) can be done without using setlocal enabledelayedexpansionwith the following line:
setlocal enabledelayedexpansion
set var=%var: =%
This works by replacing all spaces in the string with the empty string.
Source: DOS - String Manipulation