Removing spaces from a variable in batch
问题 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. This is what I have so far: @echo ON SET LOCAL EnableDelayedExpansion For %%# in (*.*) do ( SET var=%%~n# Set MyVar=%var% set MyVar=%MyVar: =% echo %MyVar%>>text.txt ) Can someone tell me whats wrong? 回答1: The reason why you are getting ECHO is on. is because delayed expansion was not used, which caused the value of %var% and %MyVar% to be