Removing spaces from a variable in batch

前端 未结 4 1240
别那么骄傲
别那么骄傲 2021-01-02 01:12

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.

4条回答
  •  被撕碎了的回忆
    2021-01-02 01:17

    Removing all spaces (not just leading and trailing) can be done without using setlocal enabledelayedexpansionwith the following line:

    set var=%var: =%
    

    This works by replacing all spaces in the string with the empty string.

    Source: DOS - String Manipulation

提交回复
热议问题