PDA

View Full Version : Help - renaming files


MJS
09-Nov-2006, 13:16
Guys

As a useful source of information on all things.... I thought I'd try asking this here...

We have to rename a whole bunch of files - somewhere in the region of 7500 to be precise. But, we need to retain the original name and append a revision number to them, so AB12345.xyz would become AB12345rev1.xyz

Is there an easy way of doing this? Any useful little power tool that can be downloaded and used for it?

Thanks for any advice - don't want to have to get someone to go through and rename them all manually

Cheers
Martin

Red-Duc
09-Nov-2006, 13:21
Dont know much about this really but Can you not just save a copy of the files into another folder and call it revisions,

MJS
09-Nov-2006, 13:27
Dont know much about this really but Can you not just save a copy of the files into another folder and call it revisions,

No, it's to send to a sub-contractor, and with several thousand files floating about, they will inevitably get mixed up... and contractually we're obliged to name the files as such...

Red-Duc
09-Nov-2006, 13:33
well I hope someone can come up with an answer for you, I wouldnt fancy that job of renaming them all individually

antonye
09-Nov-2006, 13:34
Save this as "rename.vbs" in the target directory.

Edit it so that the sPath is the name of the folder, and the sExt
is the name of the extension you wish to check (to filter for
just .gif files, for example).


Double click it in Windows Explorer and it should do the trick.


-- 8< -- cut here -- 8< --


sPath = "c:\temp\folder\"
sExt = ".gif"


Set fsoObject = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fsoObject.GetFolder(sPath)
for each fsoFile in fsoFolder.Files
if (Right(fsoFile.Name, Len(sExt)) = sExt) then
sNewName = Replace(fsoFile.Name, ".", "_rev1.")
fsoFile.Name = LCase(sNewName)
end if
next
Set fsoFolder = Nothing
Set fsoObject = Nothing

Gizmo
09-Nov-2006, 13:39
if you can't find a windoze program copy the files onto a mac and run the automater action "rename finder items", select "add text", "after name" add rev1 and it'll batch rename them for you, you can create a copy if you don't want to rename the original files.

phil_h
09-Nov-2006, 13:41
Nice idea antony.
Be brave martin, he's teaching you how to use script files :)

BUT !!!
test it out on something simple first ;)

MJS
09-Nov-2006, 13:50
Save this as "rename.vbs" in the target directory.

Edit it so that the sPath is the name of the folder, and the sExt
is the name of the extension you wish to check (to filter for
just .gif files, for example).


Double click it in Windows Explorer and it should do the trick.


-- 8< -- cut here -- 8< --


sPath = "c:\temp\folder\"
sExt = ".gif"


Set fsoObject = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fsoObject.GetFolder(sPath)
for each fsoFile in fsoFolder.Files
if (Right(fsoFile.Name, Len(sExt)) = sExt) then
sNewName = Replace(fsoFile.Name, ".", "_rev1.")
fsoFile.Name = LCase(sNewName)
end if
next
Set fsoFolder = Nothing
Set fsoObject = Nothing

Cheers for that.... as Phil says, I'll try it on something simple first.....!

Martin

antonye
09-Nov-2006, 13:52
Heh, obviously!

PS. Where do I send the bill?

MJS
09-Nov-2006, 13:56
Heh, obviously!

PS. Where do I send the bill?

Poland... You take Zloty? :D

antonye
09-Nov-2006, 14:06
Poland... You take Zloty? :D

Gdzie są moje pieniądze?

Jesteś taka uprzejma ;)

748mart
09-Nov-2006, 14:21
whats wrong with good old dos

ren *.* *rev1.*

MJS
09-Nov-2006, 14:32
Gdzie są moje pieniądze?

Jesteś taka uprzejma ;)


Twoj czek jest na poczcie

dziekuje ;)

Iconic944ss
09-Nov-2006, 20:01
or

http://www.stintercorp.com/br.php?app=BatchRenameEXE1048

Be careful...its pretty powerful ;)

moto748
09-Nov-2006, 23:31
whats wrong with good old dos

ren *.* *rev1.*


That's just what I was going to say!

I often use DOS or, as it's seems to be known now, Command Prompt (I know it's not exactly the same thing, but it doesn't make any practical difference) to rename and search for files.