Page 1 of 1

Rename multiple files

Posted: 08 Sep 2008 10:49
by halleluuja
Hello,

I would need some help with writing the .bat file that renames all files with same extension (let's say .jpg) in one folder as numeric row.

The original files are:
somefile.jpg
anotherfile.jpg
onemorefile.jpg
. . . . .
(and so on)

And the result supposed to be:
1.jpg
2.jpg
3.jpg
. . .
(etc)

Any ideas?

Thank you

Posted: 08 Sep 2008 18:00
by greenfinch

Code: Select all

SETLOCAL

set filecount=1
for /f %%a in ('dir /on /b *.jpg') do (call :rename %%a)
GOTO :EOF


:rename
ren %1 %filecount%.jpg
set /a filecount+=1
GOTO:EOF


This will sort by filename (dir /on) - run dir /? for other options

Posted: 17 Jun 2009 22:22
by k3lvinmitnick.co.cc
Nice topic,
Tks,