@echo off
Setlocal enabledelayedexpansion
Set "Pattern=rename"
Set "Replace=reuse"
For %%a in (*.jpg) Do (
Set "File=%%~a"
Ren "%%a" "!File:%Pattern%=%Replace%!"
)
This renames .jpg having substring rename
.Ref: How to rename file by replacing substring using batch in Windows Can anyone make me understand, How the For loop
does this job? Additionally: is it possible to use a /f
switch here, to get rid of Access Denied
.