Getting file properties using a batch file

半腔热情 提交于 2019-12-31 02:34:05

问题


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


回答1:


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.




回答2:


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!



来源:https://stackoverflow.com/questions/6494616/getting-file-properties-using-a-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!