首页 电脑 电脑学堂 查看内容

VBS批量修改文件扩展名

2009-7-8 09:58 705 0

摘要:   将 C:Scripts 文件夹中的所有 .log 文件的文件扩展名更改为 .txt   strComputer = "."  Set objWMIService = GetObject("wi...
关键词: objFile objWMIService strComputer strNewName errResult FileList Scripts 文件 扩展名 impersonationLev

  将 C:\Scripts 文件夹中的所有 .log 文件的文件扩展名更改为 .txt   strComputer = "."  Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")  Set FileList = objWMIService.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='c:\Scripts'} Where " & "ResultClass = CIM_DataFile")  For Each objFile In FileList  If objFile.Extension = "log" Then  strNewName = objFile.Drive & objFile.Path & objFile.FileName & "." & "txt"  errResult = objFile.Rename(strNewName)  Wscript.Echo errResult  End If  Next
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部