找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 3674|回复: 0

Change the file extension name

[复制链接]

96

主题

158

回帖

4

精华

核心会员

积分
6513
发表于 2012-6-6 05:38:59 | 显示全部楼层 |阅读模式
说明

将 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

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

快速回复 返回顶部 返回列表