Batch rename of files

Generic / N/A
April 15, 2009 at 14:58:08
Specs: Windows XP, AMD3800/2gb
I have some files to rename. They are in a bunch of small folders in a large folder. Each small folder has 5 files. Each file is currently labeled similar to the following, with a 4 digit number, a space, the filename and extension.

0021 filename.exe
0022 filename.exe
0028 filename.exe
0032 filename.exe
0045 filename.exe

I need to renumber the files in each folder 01 to 05 and then delete the old 4 digit number.

If anyone can help me, I would really be grateful

See More: Batch rename of files

Report •

April 15, 2009 at 19:13:02
I should have said: add 01-05 to the begining of the filenames ahead of the current 4 digit number, and then delete the 4 digit number. They should then end up as:
01 filename.ext
02 filename.ext
03 filename.ext
04 filename.ext
05 filename.ext

By the way, this is not a one time deal. I have been doing it manually for a while and it's getting kinda tiresome. :-)

Report •

April 17, 2009 at 03:39:25
I have been away for a while and you probably will not be interested anymore. But as I have seen you are a frequent helper I will still post. I am pushed for time and so it is a simple adapted script. I am assuming that you have a few folders that need to have this rename and count done so have put in pushd so you can enter a folder name. Change this as needed.
Sorry if this is not to your standard I am no great shakes at batch I just wanted to help.

@echo off

SET /P Choice= Enter folder:-^>
::This obviously needs to be changed
pushd "D:\Path\To Your File\%Choice%"
SET Count=1
SET New=filename
SET Extension=exe
set Extension1=ext
For %%A in (*.%Extension%) Do Call :NUM %%A
Set Count=


Ren "%*" "0%Count% %New%".%Extension1%
Set /A Count+=1

set count=1
for %New% in (*.%Extension%) do (
set name=%New%
call :countadd
set /a count=count+1
ren %0Count% %New% .%Extension1%
goto :eof

Report •

April 17, 2009 at 10:34:25
Shaka, you are the man (or lady as the case may be). ;-)

It worked beautifully, and has rid me of one of my really boring and annoying tasks.

Thank you very, very much!!!!

Report •

Related Solutions

April 17, 2009 at 13:00:58
I will undoubtedly run into you reading the XP forum. Glad to have helped, I am a geezer!

Report •

April 17, 2009 at 16:00:28
I am a geezer also, Shaka. Gonna make 80 in a few months. :-)

Thanks again!

Report •

Ask Question