VBS代码获取音频文件的长度

VBS代码获取音频文件的长度

本文介绍了VBS代码获取音频文件的长度。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi All,

I have a vbs code using this code i am able to get Path, Name, Size (kb), Type, Date Created, Date Last Accessed and Date Laste Modified data from a folder having audio files but i am not able to get Length of each audio files i have try-strFileSize = objFile.Length but i am getting error Object doesn't support this property or method: 'objFile.Length' please help me to correct this code.

Regrads





我尝试过:





What I have tried:

Dim objFSO, startFolder, OlderThanDate
'Flags for files
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
' Flags for browse dialog
Const BIF_returnonlyfsdirs   = &H0001
Const BIF_dontgobelowdomain  = &H0002
Const BIF_statustext         = &H0004
Const BIF_returnfsancestors  = &H0008
Const BIF_editbox            = &H0010
Const BIF_validate           = &H0020
Const BIF_browseforcomputer  = &H1000
Const BIF_browseforprinter   = &H2000
Const BIF_browseincludefiles = &H4000
currentScriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
reportFile = currentScriptPath & "FilePropertiesReport.csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDlg = WScript.CreateObject("Shell.Application")
Set objShell = CreateObject("WScript.Shell")
' Use the BrowseForFolder method.
Set objStartFolder = objDlg.BrowseForFolder (&H0, _
 "Select the folder you want to report on, su folder will also be reported", BIF_editbox + BIF_returnonlyfsdirs)
' Here we use TypeName to detect the result.
If InStr(1, TypeName(objStartFolder), "Folder") > 0 Then
	startFolder = objStartFolder.ParentFolder.ParseName(objStartFolder.Title).Path
	'Create report file and add CSV Header
	Set objReportFile = objFSO.CreateTextFile(reportfile, ForWriting)
	objReportFile.Write("Path, Name, Size (kb), Type, Date Created, Date Last Accessed, Date Laste Modified,Length"  & chr(13) & chr(10))
	'Run the function
	ReportFiles startFolder
	'Close the report
	objReportFile.Close
	'Ask to open the report now or just close
	strMbox = MsgBox("Reporting Complete. " & chr(13) & chr(10) &"The report has been saved to: " & reportFile & chr(13) & chr(10) & chr(13) & chr(10) & "Would you like to open the report now?",4,"Open report now?")
	if strMbox = 6 Then
		objShell.Run reportFile
	End if
Else
	MsgBox "An error has occured."
End if

'----------------------------------------------
' Function
'----------------------------------------------
Function ReportFiles(folderName)
   Dim objFolder, objFile, fileCollection, folderCollection, subFolder
   Set objFolder = objFSO.GetFolder(folderName)
   Set fileCollection = objFolder.Files
   For Each objFile In fileCollection
		strFilePath = chr(34) & objFile.Path & chr(34)
		strFileName = chr(34) & objFile.Name & chr(34)
		strFileSize = objFile.Size / 1024
		strFileType = chr(34) & objFile.Type & chr(34)
		strFileDateCreated = objFile.DateCreated
		strFileDateLastAccessed = objFile.DateLastAccessed
		strFileDateLastModified = objFile.DateLastModified
                strFileLength = objFile.Length
		objReportFile.Write(strFilePath & "," & strFileName & "," & strFileSize & "," & strFileType & "," & strFileDateCreated & "," & strFileDateLastAccessed & "," & strFileDateLastModified & "," & strFileLength & chr(10))
   Next
	'Loop for each sub folder
    Set folderCollection = objFolder.SubFolders
    For Each subFolder In folderCollection
       ReportFiles subFolder.Path
    Next
End Function

推荐答案


这篇关于VBS代码获取音频文件的长度。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 01:36