rename extention of a file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
penpen
Expert
Posts: 1988
Joined: 23 Jun 2013 06:15
Location: Germany

Re: rename extention of a file

#1 Post by penpen » 15 Jan 2021 17:05

You might do something like that (sketched and untested):

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion

set "N=1000000000"
for %%a in ("*12345-*" "*-*12345") do (
	for /f "tokens=* delims=" %b in ('set /a "N"') do (
		echo(ren "%%~a" "%%~b.txt"
	)
	set /a "N+=1"
)

goto :eof
Sidenote: I echoed the commands it should do, so you can check if that's what you like to perform.
In case you are satisfied with the commands created, you might want to delete the "echo(".


penpen

Post Reply