1.

Solve : Rename Various files with a batch file?

Answer»

I have a lot of .jpg's in one folder with a lot of different names. I want to rename them all in sequence i.e. 10001.jpg, 10002.jpg and so on. Or even with names like a.jpg, B. jpg or even aa.jpg, ab.jpg ac.jpg...

Can anyone shed light on how to do this?

Thanksthis is what i got...not really much to explain...except this will rename all files jpg in order 0 - xxx.

change "C:\path\of\files\" for the path of your files
Code: [SELECT]:begin
set count=1
cd
FOR /F "tokens=*" %%f IN ('dir /A-d /b') do (call :filecount "%%f")
:filecount
set /a count+=1
for /f %%a in ('dir /w /b "*.jpg"')do (
for /l %%b in ('1,1,%count%') do (
ren %%a %%b.jpg
)
)@echo off&setlocal enabledelayedexpansion
(for %%a in (*.jpg) do echo "%%a")>jpg.tmp
set i=0
for /f %%a in (jpg.tmp) do (
set /a i+=1
ren %%a !i!.jpg
)
del jpg.tmpCode: [Select]@echo off&setlocal enabledelayedexpansion
set i=0
(for %%a in (*.jpg) do (
set /a i+=1
ren %%a !i!.jpg
)



Discussion

No Comment Found