Hi,
I'm trying to find a easy way to rename multiple filenames on the command line or using the batch file:
The original files like:
abc01.txt, abc02.txt ... abc15.txt
to
defgh01.txt, defgh02.txt ... defgh15.txt
or to
de01.txt de02.txt ... de15.txt
Thanks in advance,
- Coraties
Rename multiple filenames on the command line or batch file
Moderator: DosItHelp
Re: Rename multiple filenames on the command line or batch f
Code: Select all
@echo off &setlocal enableextensions
set "old=abc"
set "new=defgh"
for /f "delims=" %%f in ('dir /b/a-d "%old%??.*" ^|findstr /rc:[0-9][0-9]\.txt$') do (
set "num=%%~nf"
setlocal enabledelayedexpansion
set "num=!num:~-2!"
ren "%%f" "%new%!num!%%~xf"
endlocal
)