2014-01-29 48 views
3

我正在尋找獲取指定文件(或文件目錄)的元數據。我正在尋找.WTV文件的「程序說明」。Powershell獲取文件的元數據

我找到了代碼,但沒有列出該屬性。其中一些代碼如下所示:

foreach($sFolder in $folder) 
    { 
    $a = 0 
    $objShell = New-Object -ComObject Shell.Application 
    $objFolder = $objShell.namespace($sFolder) 

    foreach ($strFileName in $objFolder.items()) 
    { FunLine("$($strFileName.name)") 
     for ($a ; $a -le 266; $a++) 
     { 
     if($objFolder.getDetailsOf($strFileName, $a)) 
      { 
      $hash += @{ ` 
        $($objFolder.getDetailsOf($objFolder.items, $a)) =` 
        $($objFolder.getDetailsOf($strFileName, $a)) 
        } #end hash 
      $hash 
      $hash.clear() 

我可以在文件資源管理器中看到該屬性。

回答

0

抓住TagLib# from Nuget或各種其他地方。然後看看這個blog post showing how to use TagLib# to edit MP3 tags。希望它可以檢索你正在尋找的WTV標籤。

+0

我用過TagLib。這是針對ID3v1和ID3v2標籤的音頻文件。 – user1612851

+0

嗯,taglib-sharp聲稱它是一個用於在媒體文件中讀取和寫入元數據的庫,包括**視頻**,音頻和照片格式。 –

+0

好的...與TagLib不同。我會看一看。 – user1612851

0
$shell = new-object -comobject shell.application 
$ShFolder=$shell.namespace("\\MEDIA\Recorded Tv\") 
$ShFile =$ShFolder.parsename("Person of Interest_WBBMDT_2013_11_26_21_01_00.wtv") 

$count = 0 

while ($count -le 294) 
    { 
    $ShRating = $ShFolder.getdetailsof($ShFile,$count) 

    $count 
    $ShRating 
    $count = $count+1 
    } 

程序說明是項目272

1

的代碼你有@ user1921849幾乎得到它,但更清楚你應該使用Windows Shell中的產權制度命名的屬性,在http://msdn.microsoft.com/en-us/library/windows/desktop/ff521714(v=vs.85).aspx上市解決了原來的問題用於WTV文件,並在下面的第4行中使用。

$shell = new-object -com shell.application 
$folder = $shell.namespace("\\MEDIA\Recorded Tv\") 
$item = $folder.Items().Item('Person of Interest_WBBMDT_2013_11_26_21_01_00.wtv') 
write-output $item.ExtendedProperty('System.RecordedTV.ProgramDescription')