Remove spaces from the beginning
old: ^ (.*)#
new: \1
Remove spaces from the end
old: (.*) .([^.]+)#
new: \1.\2
And you can use this extract of the Steve's script [Titlecase) to remove multispaces and strip leading/trailing spaces.
[code]@script vbscript
option explicit
dim fMultiSpace
dim fStripSpaces
fMultiSpace = True ' Remove multiple spaces
fStripSpaces = True ' Strip leading/trailing spaces
Function Rename_GetNewName ( strFileName, strFullPath, _
fIsFolder, strOldName, ByRef strNewName )
dim strExt
dim iOldLength
dim iNewLength
'Strip the filename extension for now
if fIsFolder = False then
if InStr(strNewName, ".") then
strExt = Right(strNewName, Len(strNewName)-(InStrRev(strNewName, ".")-1))
strNewName = Left(strNewName, InStrRev(strNewName, ".")-1)
else
strExt = ""
end if
end if
' Remove all multiple spaces
if fMultiSpace = True then
iNewLength = 0
iOldLength = len(strNewName)
Do While iOldLength > iNewLength
iOldLength = len(strNewName)
strNewName = Replace(strNewName," "," ")
iNewLength = len(strNewName)
Loop
end if
' Strip leading/trailing spaces
if fStripSpaces = True then
strExt = Trim(strExt)
strNewName = Trim(strNewName)
end if
' Rejoin the name and extension and we're finished
strNewName = strNewName & strExt
End Function[/code]
And try my Rename Tollbar (see signature)