Ducati Sporting Club UK

Ducati Sporting Club UK (/msgboard.php)
-   Idle Chat (/forumdisplay.php?f=102)
-   -   Help - renaming files (/showthread.php?t=38651)

MJS 09-Nov-2006 13:16

Help - renaming files
 
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

Quote:

Originally Posted by Red-Duc
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

Quote:

Originally Posted by antonye
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

Quote:

Originally Posted by antonye
Heh, obviously!

PS. Where do I send the bill?


Poland... You take Zloty? :D


All times are GMT +1. The time now is 22:02.

Powered by vBulletin 3.5.4 - Copyright © 2000 - 2025, Jelsoft Enterprises Ltd.
© Ducati Sporting Club UK