0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ファイル名一括置換 VBScript

Posted at

スクリプトファイルに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 & " 件のファイル名を変更しました"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?