Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: AlwaysWillingToLearn
Hi all,
this is prob very basic for you guys, erm i have a folder with about 4000 pictures, and they are randomly named A1(0) A1(1) etc i want to name them all 001, 002, 003, 004 ect, keep in mind there are Jpgs and Bmp files, any ideas where to start please?
I should google this but i thought if someone could provide some code it will one be easier (lol) and two i can attempt to modify it for some other stuff i want to do.
thanks,

@echo off
setLocal EnableDelayedExpansion:main
for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set /a N+=1
call :sub1
echo ren %%a !S!%%~Xa
)
goto :eof:sub1
set S=!N!
:pad
if !S:~4^,1!'==' set S=0!S!& goto :pad
goto :eof
=====================================
If at first you don't succeed, you're about average.M2

if you can use Python on your system, you can use the script here .
actual usage:
C:\test>dir /B A*
A1(0)
A1(1)
A1(2)
A1(3)
To show a listing of files to be renamed, use -l
C:\test>filerenamer.py -s "A1\(.*\)" -e "001:999" -l "A*"
To be renamed or deleted): [ C:\test\A1(0) ] to [ C:\test\001 ]
To be renamed or deleted): [ C:\test\A1(1) ] to [ C:\test\002 ]
To be renamed or deleted): [ C:\test\A1(2) ] to [ C:\test\003 ]
To be renamed or deleted): [ C:\test\A1(3) ] to [ C:\test\004 ]
To actually rename the files, remove the -l option
C:\test>filerenamer.py -s "A1\(.*\)" -e "001:999" "A*"
C:\test\A1(0) is renamed to C:\test\001
C:\test\A1(1) is renamed to C:\test\002
C:\test\A1(2) is renamed to C:\test\003
C:\test\A1(3) is renamed to C:\test\004C:\test>dir /B A*
File Not FoundC:\test>dir /B 0*
001
002
003
004

Thanks to both for replying,
ghostdog, i dont actually use python and am not sure how to even if i were to, but what you have suggested looks pretty cool, so thanks for taking the time help me.
M2, i pasted the code into wordpad then done a save as and saved it as "renamer.bat".
i place the bath file into the folder where all the picture are, for exaple the pictures are in a folder called 'Photos' so i placed the batch into the 'photos' folder and ran it but nothing happend, any ideas please?
Thanks,

As written, it doesn't -DO- the rename; it just previews what's to be done. To activate it, edit out the ECHO before REN.
=====================================
If at first you don't succeed, you're about average.M2

![]() |
Append tags in XML using ...
|
Batch file to delete fold...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |