Removing spaces from a variable in batch

前端 未结 4 1236
别那么骄傲
别那么骄傲 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:37

    Run the following batch in the folder holding the files to be renamed

        @echo off
        setlocal enabledelayedexpansion
        for %%j in (*.*) do (
        set filename=%%~nj
        set filename=!filename=.=_!
        set filename=!filename= =_!
        if not "!filename!"=="%%~nj" ren "%%j" "!filename!%%~xj"
        )
    

    you just need to add the print to txt

提交回复
热议问题