Renaming files with spaces and dots in the filename
问题 I'm making a simple *bat file with drag/drop ability for replacing white spaces( ) and dots(.) for underscores(_). I think this should work, but it doesn't: @ECHO OFF setlocal enabledelayedexpansion FOR %%f IN (%*) DO ( set filename=%%~nj set filename=!filename:.=_! set filename=!filename: =_! if not "!filename!"=="%%~nf" RENAME "%%f" "!filename!%%~xf" ) Do you know what is going on? 回答1: try this: @ECHO OFF &setlocal FOR %%f IN (%*) DO ( set "oldname=%%~ff" set "oldfname=%%~nf" set