Jump to content

_GetExtendedProperties


ripdad
 Share

Recommended Posts

This is my version of similar scripts using ObjCreate('shell.application').

It returns various info depending on what file type you want properties from.

On my tests, Win_XP returned 40 items, while WIN_7 returned 284 items.

There doesn't seem to be a way to get the items count, hence the silly ReDims.

On 2 XP machines (SP2,SP3)...

"width", "height" and "time stamp" titles are blank, hence the manual input.

Returns a 2D array with "property titles" in column 0 and "property values" in column 1.

; _GetExtendedProperties
; Released: April 07, 2011 by ripdad
; Example: Yes

#include <array.au3>

Local $sPath = FileOpenDialog('Select file', '', '(*.*)')
If Not $sPath Then Exit
Local $array = _GetExtendedProperties($sPath)
If Not @error Then _ArrayDisplay($array)
Exit

Func _GetExtendedProperties($sPath)
    If Not FileExists($sPath) Then Return SetError(-1)
    Local $sDir = StringLeft($sPath, StringInStr($sPath, '\', 0, -1) - 1) & '\'
    Local $sFile = StringTrimLeft($sPath, StringInStr($sPath, '\', 0, -1))
    Local $oShellApp = ObjCreate('shell.application')
    If Not IsObj($oShellApp) Then Return SetError(-2)
    Local $oDir = $oShellApp.NameSpace($sDir)
    If Not IsObj($oDir) Then Return SetError(-3)
    Local $oFile = $oDir.ParseName($sFile)
    If Not IsObj($oFile) Then Return SetError(-4)
    Local $ItemTitle, $ItemValue, $aProperty[1][2]
    For $i = 1 To 300
        $ItemTitle = $oDir.GetDetailsOf($oDir.Items, $i - 1)
        $ItemValue = $oDir.GetDetailsOf($oFile, $i - 1)
        If Not $ItemTitle And $i > 34 Then ExitLoop
        ReDim $aProperty[$i + 1][2]
        $aProperty[0][0] = $i
        $aProperty[$i][0] = $ItemTitle
        $aProperty[$i][1] = $ItemValue
    Next
    If @OSVersion = 'WIN_XP' Then
        $aProperty[28][0] = 'Width'
        $aProperty[29][0] = 'Height'
        $aProperty[32][0] = 'Time Stamp'; or # or ?
    EndIf
    Return SetError(0, 0, $aProperty)
EndFunc

-Edit-

Below is related to the above script with the exception that it

gets the properties that is displayed on the Explorer Status Bar.

; _ShellStatusBarProperties

; Released: April 08, 2011 by ripdad
; Example: Yes

#include <array.au3>

Local $sPath = FileOpenDialog('Select file', '', '(*.*)')
If Not $sPath Then Exit
Local $array = _ShellStatusBarProperties($sPath)
If Not @error Then _ArrayDisplay($array)
Exit

Func _ShellStatusBarProperties($sPath)
    If Not FileExists($sPath) Then Return SetError(-1)
    Local $sDir = StringLeft($sPath, StringInStr($sPath, '\', 0, -1) - 1) & '\'
    Local $sFile = StringTrimLeft($sPath, StringInStr($sPath, '\', 0, -1))
    Local $oShellApp = ObjCreate('shell.application')
    If Not IsObj($oShellApp) Then Return SetError(-2)
    Local $oDir = $oShellApp.NameSpace($sDir)
    If Not IsObj($oDir) Then Return SetError(-3)
    Local $oFile = $oDir.ParseName($sFile)
    If Not IsObj($oFile) Then Return SetError(-4)
    Local $aProperty = StringSplit($oDir.GetDetailsOf($oFile, -1), @LF)
    Return SetError(0, 0, $aProperty)
EndFunc
Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...