Computing.Net > Forums > Programming > Batch Rename all files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Rename all files

Reply to Message Icon

Name: AlwaysWillingToLearn
Date: September 19, 2008 at 04:16:28 Pacific
OS: Winxp pro sp3
CPU/Ram: 2gig DDR2
Product: Gigabyte
Comment:

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,



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 19, 2008 at 07:13:38 Pacific
Reply:

@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


0

Response Number 2
Name: ghostdog
Date: September 19, 2008 at 18:47:31 Pacific
Reply:

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\004

C:\test>dir /B A*
File Not Found

C:\test>dir /B 0*
001
002
003
004



0

Response Number 3
Name: AlwaysWillingToLearn
Date: September 20, 2008 at 08:52:47 Pacific
Reply:

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,


0

Response Number 4
Name: Mechanix2Go
Date: September 20, 2008 at 09:44:58 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Append tags in XML using ... Batch file to delete fold...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Rename all files

batch rename files consecutive n° www.computing.net/answers/programming/batch-rename-files-consecutive-n/15480.html

rename adding prefix to all files www.computing.net/answers/programming/rename-adding-prefix-to-all-files/17546.html

Commas crash batch renaming? www.computing.net/answers/programming/commas-crash-batch-renaming/20368.html