0
工作考慮下面的VBScript其中,在運行時,列出當前目錄下的所有文件及其屬性:GetDetailsOf失敗時「爲隱藏已知文件類型的擴展名」選擇
Option Explicit
Dim oShell : Set oShell = CreateObject("Shell.Application")
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oFolder : Set oFolder = oShell.Namespace(oFSO.GetParentFolderName(Wscript.ScriptFullName))
Dim oFile, iPos, sHeader(999), sVal
' Get a list of the property names
For iPos = 0 to 999
sHeader(iPos) = oFolder.GetDetailsOf(oFolder.Items, iPos)
Next
' For each file in this folder, print the property name and the value
For Each oFile in oFolder.Items
WScript.Echo "Looking at " & oFile.Name
For iPos = 0 To 999
sVal = oFolder.GetDetailsOf(oFolder.ParseName(oFile.Name), iPos)
If sVal <> "" Then WScript.Echo sHeader(iPos) & " (" & iPos & "): " & sVal
Next
Next
如果我運行這個如果我再次運行此
D:\defect>cscript //NOLOGO list_metadata.vbs Looking at list_metadata.vbs Name (0): list_metadata.vbs Size (1): 740 bytes Item type (2): VBScript Script File Date modified (3): 19/02/2012 12:26 Date created (4): 23/02/2012 22:16 Date accessed (5): 23/02/2012 22:16 Attributes (6): A Perceived type (9): Unspecified Owner (10): HOME\Richard Kind (11): Program Rating (19): Unrated Computer (53): HOME (this computer) Filename (155): list_metadata.vbs Shared (173): No Folder name (176): defect Folder path (177): D:\defect Folder (178): defect (D:) Path (180): D:\defect\list_metadata.vbs Type (182): VBScript Script File Link status (188): Unresolved Sharing status (269): Not shared
然而「:即只包含這個文件,並與Windows設置「隱藏已知文件類型」禁用,然後我得到以下的(正確)的輸出文件夾中個啓用了已知文件類型的「隱藏擴展,那麼每個項目的價值是完全一樣的性質,並在第一行的文件的名稱缺少擴展:
D:\defect>cscript //NOLOGO list_metadata.vbs Looking at list_metadata Name (0): Name Size (1): Size Item type (2): Item type Date modified (3): Date modified ...lots deleted... Frame width (285): Frame width Total bitrate (286): Total bitrate Masters Keywords (debug) (287): Masters Keywords (debug) Masters Keywords (debug) (288): Masters Keywords (debug)
有誰知道我可以修改此代碼,以使其可以工作,而不管該設置是否應用於Windows?
愚蠢? :)它像一個魅力工作,謝謝。 – Richard 2012-02-24 20:11:58