如何使用vbs重命名文件

来源:百度知道 编辑:UC知道 时间:2024/06/08 13:07:54
如何使用vbs,删除文件名称包含”123”的字符串,比如说文件12315,12314要删除他们开头的123

strFolder = "e:\temp"

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

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

Set objFSO = Nothing

请按实际更改路径和文件扩展名。