用脚本批量文件重命名(VBScript)

''' filename: rename.vbs
''' http://blog.csdn.net/maray


strFolder = "C:\Users\result\"


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
Set colFiles = objFolder.Files


For Each strFile in colFiles
    If Lcase(objFSO.GetExtensionName(strFile)) = "png" Then
       strNewName = Replace(strFile.Name, "_副本.png", ".png")
       objFSO.MoveFile strFile, strFolder & "\" & strNewName
    End If
Next


Set objFSO = Nothing 


有如下文件,利用上面的脚本rename.vbs可以将其批量改名,去掉“_副本"后缀


输入文件:

C:\Users\result\JPG1001_副本.png
C:\Users\result\JPG1002_副本.png
C:\Users\result\JPG1003_副本.png


C:\Users\result\JPG1004_副本.png
C:\Users\result\JPG1005_副本.png

C:\Users\result\JPG1006_副本.png




输出文件:

C:\Users\result\JPG1001.png
C:\Users\result\JPG1002.png
C:\Users\result\JPG1003.png
C:\Users\result\JPG1004.png
C:\Users\result\JPG1005.png


C:\Users\result\JPG1006.png


你可能感兴趣的:(c,脚本,VBScript,each)