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