当前位置:DOS资源站资料中心VBS脚本 → VBS读取MP3文件信息

VBS读取MP3文件信息

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-6-2 15:23:17

    arrFile = MyGetFile()
Set oShell = CreateObject("Shell.Application")
Set oDir = oShell.NameSpace(arrFile(1) + "\")
Set oFile = oDir.ParseName(arrFile(0))
For i = 0 To 100
    sTmp = oDir.GetDetailsOf(,i) + vbTab
    If sTmp = vbTab Then Exit For
    sPrint = sPrint + vbCrLf + sTmp + vbTab + _
                 oDir.GetDetailsOf(oFile,i)
Next
WScript.Echo sPrint

Set oFile = Nothing
Set oDir = Nothing
Set oShell = Nothing

'***********************************************************************************
'获得要操作的文件,返回一个包含文件名和路径的数组
'***********************************************************************************
Function MyGetFile()

On Error Resume Next
Dim strFile,objFso,objFile
    If WScript.Arguments.Count < 1 Then
        Set objDialog = CreateObject("UserAccounts.CommonDialog")
        objDialog.Filter = "mp3 文件|*.mp3|wma 文件|*.wma|wav 文件|*.wav|所有 文件|*.*"
        objDialog.ShowOpen
        strFile = objDialog.FileName
        Set objDialog = Nothing
    Else
        strFile = WScript.Arguments(0)
    end if
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.GetFile(strFile)
    If Err Then
        If Err.Number = 5 Then WScript.Quit
        WScript.Echo Err.Description
        Err.Clear
        WScript.Quit
    Else
        MyGetFile = Array(objFile.Name,objFile.ParentFolder)
    End If
   
Set objFile = Nothing
Set objFso = Nothing

End Function