Saturday, June 22, 2013

Read Extended Attribute from Windows Media Center TV Show

If you need to read an extended attribute for a Windows Media Center TV show, then this is how you have to do it. The trick is you have to parse the folder, it cannot be read from the file itself.

This little function takes a path and file name as the first variable and the attribute name as the second parameter.

Function GetAttribute
   Param([String] $r, [String] $a) # r = file, a = attribute
   [String] $private:p = ""
   [String] $private:f = ""
   [String] $private:v = ""
   $ShellApp = New-Object -ComObject Shell.Application
   $p = Split-Path $r
   $f = Split-Path $r -leaf
   $ShellFolder = $ShellApp.Namespace($p)
   $ShellFolder.Items()|ForEach-Object `
      If($_.path -eq $r)
         $v = $_.ExtendedProperty($a)
   If($v -eq "")
      $v = "NULL"
   Return $v



No comments:

Post a Comment