' Copyright (C) 2011 TechHit. All rights reserved.
'
' THIS SCRIPT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
'


Option Explicit

Function ScrubFilename(strIn)
	Dim strOut

	strOut = strIn
	Dim strReplaceChars
	strReplaceChars = Split("\ / : ; < > { } % * & # ~ ? ( )")

	Dim chrReplace
	For Each chrReplace in strReplaceChars
		strOut = Replace(strout, chrReplace, "-")
	Next

	ScrubFilename = strOut
End Function


Dim wshShell, fso

Set wshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strSavedFileName, strFolderName, strFileName, strScrubbedName, strNewFileName

strSavedFileName = Wscript.Arguments(0)
strFolderName = fso.GetParentFolderName(strSavedFilename)
strFileName = fso.GetFileName(strSavedFileName)
strScrubbedName = ScrubFilename(strFileName)
strNewFileName = fso.BuildPath(strFolderName, strScrubbedName)
'WScript.Echo(strNewFileName)
fso.MoveFile strSavedFileName, strNewFileName

