スクリプトファイルにD&Dした複数ファイルのファイル名を一括置換する
ReNameAll.vbs
Option Explicit
Dim oldStr, newStr, n, arg, argName, newName
oldStr = InputBox("置換前の文字列を入力してください。", , "")
newStr = InputBox("置換後の文字列を入力してください。", , "")
n = 0
With CreateObject("Scripting.FileSystemObject")
For Each arg In WScript.Arguments
argName = .GetFile(arg).Name
If InStr(argName, oldStr) > 0 Then
newName = Replace(argName, oldStr, newStr)
If Not .FileExists(.BuildPath(.GetParentFolderName(arg), newName)) Then
.GetFile(arg).Name = newName
n = n + 1
End If
End If
Next
End With
CreateObject("SAPI.SpVoice").Speak n & " 件のファイル名を変更しました"