开发者

Getting file properties using a batch file

I was wondering if it is possible to get the properties of开发者_运维技巧 selected files using a batch file. I only found a winbatch example that was able to do this. Any suggestions are welcome. Thanks


For standard Windows file properties, use WMIC DATAFILE.

Some file formats (for example .mp3 in the ID3 headers) have well known properties. Eventhough some of them might be shown by Explorer, not all of them are available through WMIC DATAFILE.

And finally many other document properties in custom file formats are stored without easy (or even possible at all) external access.


Using VBScript, I was able to display the last author and manager from a recent Word 2010 document I created:

Option Explicit

Const Schema_LastAuthor = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 8"
Const Schema_Manager = "{D5CDD502-2E9C-101B-9397-08002B2CF9AE} 14"

Dim Shell
Set Shell = CreateObject("Shell.Application")

If (Not Shell Is Nothing) Then

    Dim ThisFolder
    Set ThisFolder = Shell.NameSpace("YOUR_FOLDER_HERE")

    If (Not ThisFolder Is Nothing) Then

        Dim ThisFolderItem
        Set ThisFolderItem = ThisFolder.ParseName("YOUR_DOCUMENT_HERE")

        If (Not ThisFolderItem Is Nothing) Then

            Dim lastAuthor, manager
            lastAuthor = ThisFolderItem.ExtendedProperty(Schema_LastAuthor)
            manager = ThisFolderItem.ExtendedProperty(Schema_Manager)

            WScript.Echo "   Document:   " & ThisFolderItem.Name
            WScript.Echo "Last author:   " & lastAuthor
            WScript.Echo "    Manager:   " & manager

        End If

        Set ThisFolderItem = Nothing

    End If

    Set ThisFolder = Nothing

End If

Set Shell = Nothing

WScript.Quit

Here's more information on the Windows Property System schema for documents. Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜