' File Batch Renamer Script ' Created in 2008 by kwitcherbitchen.org ' ' http://www.kwitcherbitchen.org/ ' ' You may copy, redistribute, and modify this script as long as this line and all lines ' above it stay intact, being modified only to accomodate more credits for modifications. Dim Shell Set Shell = CreateObject("Shell.Application") Dim Filter, Folder, Files, File, Filename, FindString, ReplaceString, NewName Set Folder = Shell.BrowseForFolder(0, "Select a folder", BIF_NONEWFOLDERBUTTON) If (Folder is Nothing) Then WScript.Quit 0 Set Files = Folder.Items Filter = InputBox("Rename all files named:", "Renamer", "*") If (Filter = "") Then WScript.Quit 0 FindString = InputBox("Find all instances of:", "Renamer") If (FindString = "") Then WScript.Quit 0 ReplaceString = InputBox("Replace all instances of """&FindString&""" with:", "Renamer") If IsEmpty(ReplaceString) Then WScript.Quit 0 Function CheckName(Filter, File) Dim PartTotal, PartIndex, PartCount, FindIndex, NamePart, RetVal CheckName = True Filename = Split(LCase(Filter), "*") PartTotal = 0 For Each NamePart In Filename PartTotal = PartTotal + 1 Next PartIndex = 1 PartCount = 0 For Each NamePart In Filename FindIndex = InStr(PartIndex, LCase(File.Name), NamePart) PartIndex = FindIndex+Len(NamePart) If ((PartCount = 0 And FindIndex <> 1) Or (PartCount = PartTotal - 1 And PartIndex < Len(File.Name) + 1) Or (FindIndex = 0)) And NamePart <> "" Then CheckName = False Exit For End If PartCount = PartCount + 1 Next End Function For FNum = 0 To (Files.Count - 1) Set File = Files.Item(FNum) If CheckName(Filter, File) = True Then If (InStr(1, LCase(File.Name), LCase(FindString)) > 0) Then NewName = Replace(File.Name, FindString, ReplaceString, 1, -1, 1) File.Name = NewName WScript.Echo File.Name End If End If Next