Function UrlToFileName(strUrl) 'Takes a URL like "http://www.bar.com/movies/test.flv" and returns a file name like "bar.com-movies-test.flv" Const BAD_CHARS = "\ / : * ? < > |" Dim strName, strChar strName = strUrl If InStr(1, strName, "http://", vbTextCompare) = 1 Then strName = Mid(strName, 8) strName = Replace(strName, "//", "/") If DEBUG_MESSAGES Then Status "Name: " & strName 'We will always ignore the common "www" machine name If InStr(1, strName, "www.", vbTextCompare) = 1 Then strName = Mid(strName, 5) If Not KEEP_MACHINE_NAME Then If Not IsNumeric(Split(strName, ".")(0)) Then 'Don't treat IP address like machine.domain strName = Mid(strName, Instr(strName, Split(Split(strName, "/")(0), ".")(Ubound(Split(Split(strName, "/")(0), ".")) - 1))) If DEBUG_MESSAGES Then Status "Name: " & strName End If End If strName = UnEscape(strName) 'Replace bad characters with dashes For Each strChar In Split(BAD_CHARS) strName = Replace(strName, strChar, "-") Next If DEBUG_MESSAGES Then Status "Name: " & strName UrlToFileName = strName End Function