I am trying to replace spaces in image files and with dashes (-), for example:
this is a file.png
becomes
this-is-a-file.png
I am trying to replace spaces in image files and with dashes (-), for example:
this is a file.png
becomes
this-is-a-file.png
@echo off
setlocal disableDelayedExpansion
set "root_dir=c:\somewhere"
pushd "%root_dir%"
for %%a in ("* *.png") do (
setlocal enableDelayedExpansion
set "f_name=%%~nxa"
set "cf_name=!f_name: =-!"
ren "%%~nxa" "!cf_name!"
endlocal
)
endlocal
Check also this (which in your case will not apply)