vbscript中的批处理文件重命名

vbscript中的批处理文件重命名,vbscript,Vbscript,我有一组这样命名的文件(word可以是任何单词或数字): 我想重命名文件夹中的所有内容,使其仅包含下面的组。。。你可以指望地板总是在文件名和什么我想保持下面的地板 B2342.pdf B-2342.pdf C43.pdf E2AD342.pdf 将要处理的文件夹的路径作为第一个参数传递到此脚本。您可能需要调整输入的正则表达式 Set expr = New RegExp Set fs = CreateObject("Scripting.FileSystemObject") Set fpath =

我有一组这样命名的文件(word可以是任何单词或数字):

我想重命名文件夹中的所有内容,使其仅包含下面的组。。。你可以指望地板总是在文件名和什么我想保持下面的地板

B2342.pdf
B-2342.pdf
C43.pdf
E2AD342.pdf

将要处理的文件夹的路径作为第一个参数传递到此脚本。您可能需要调整输入的正则表达式

Set expr = New RegExp
Set fs = CreateObject("Scripting.FileSystemObject")
Set fpath = fs.GetFolder(WScript.Arguments(0))

expr.Pattern = "Floor\S*\s+([^\s.]*)"

For Each fspec In fpath.Files
    Set matches = expr.Execute(fspec.Name)
    If matches.Count = 0 Then
        WScript.StdErr.WriteLine "Invalid file name " & fspec.Name
    Else
        fspec.Move fspec.ParentFolder & "\" & matches(0).Submatches(0) & ".pdf"
    End If
Next

那么问题是什么?你不能指望有人为你写代码。试一试,如果遇到问题或有具体问题,请在此处发布。
Set expr = New RegExp
Set fs = CreateObject("Scripting.FileSystemObject")
Set fpath = fs.GetFolder(WScript.Arguments(0))

expr.Pattern = "Floor\S*\s+([^\s.]*)"

For Each fspec In fpath.Files
    Set matches = expr.Execute(fspec.Name)
    If matches.Count = 0 Then
        WScript.StdErr.WriteLine "Invalid file name " & fspec.Name
    Else
        fspec.Move fspec.ParentFolder & "\" & matches(0).Submatches(0) & ".pdf"
    End If
Next