I\'m trying to rename all the files inside a folder (all .exe files). I want to replace all the spaces with underscores, e.g. qwe qwe qwe asd.exe to qwe_q
Adapted from here:
https://stackoverflow.com/a/16129486/2000557
@echo off
Setlocal enabledelayedexpansion
Set "Pattern= "
Set "Replace=_"
For %%a in (*.exe) Do (
Set "File=%%~a"
Ren "%%a" "!File:%Pattern%=%Replace%!"
)
Pause&Exit
Create a batch file (*.bat) with the above contents. Place that batch file in the folder with all the .exe's and it will replace the spaces with underscores when you run it.