Help with regular expressions in File Renaming scripts

Hi,

I have some files which look like this:
beginning-php5-programmer-to-programmer.9780764557835.16953.chm
professional-php5-programmer-to-programmer.9780764572821.26866.chm

What I'd like to do is 1)get rid of the numbers at the end, 2)convert the dashes to spaces and make the file name title case.
I have a couple of renaming presets to do that, the first one using regular expressions. I have tried to write a script to combine both these operations, without success. The Regular expression part beats me, and I don't have a clue as to what is going wrong.

Any help would be appreciated

How far did you get? If you only need help with the correct VBScript regex syntax and are happy to modify the existing Title Case and/or Multiple-Reg Ex rename scripts then it's an easy question to answer, but if you need an entire script writing and testing then it'll take more time, of course.

As I wrote earlier, I have made two presets, one for replacing the numbers, and one for the dashes, or more precisely, hyphens. I am adding a couple of snapshots. Don't know how that will work out though. I am new to posting on forums.

The first one uses a regexp for removing the numbers, and a checkbox selection for converting to upper case (not the ideal procedure I think).

Free Image Hosting at [www.ImageShack.us](http://www.ImageShack.us)

The second one simply does a Standard search and replace for hyphens and converts them to spaces.

Free Image Hosting at [www.ImageShack.us](http://www.ImageShack.us)

Just had a look at my last reply, and found that my images had been converted to lines of HTML code. I am attaching the files below.




But i don't know why capitalize don't work

[code]@script vbscript
Option Explicit

Function Rename_GetNewName ( strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName )
Dim re
Set re = new RegExp

re.Pattern = "(.*)(\.[0-9]*)(\.[0-9]*)(\.(pdf|chm))"
strNewName = replace(re.Replace(strFileName, "$1$4"),"-"," ")

End Function[/code]

Forgot my last post and use this

[code]@script vbscript

Function Rename_GetNewName ( strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName )
Set re = new RegExp

re.Pattern = "(.*)(\.[0-9]*)(\.[0-9]*)(\.(pdf|chm))"
strNewName = pCase(replace(re.Replace(strFileName, "$1$4"),"-"," "))

End Function

Function pCase(strIn)
strOut = ""
boolUp = True
For i = 1 To Len(strIn)
c = Mid(strIn, i, 1)
if c = " " or c = "'" or c = "-" then
strOut = strOut & c
boolUp = True
Else
If boolUp Then
tc = Ucase(c)
Else
tc = LCase(c)
End If
strOut = strOut & tc
boolUp = False
End If
Next
pCase = strOut
End Function
[/code]
amitava.orp (1.12 KB)

Thanks for your response. I'll give you script a shot and let you know.

Once again, thank you very much.

Works like a dream! Just what I needed :smiley:. Thanks a lot