Powershell获取文件的元数据

标签 powershell metadata

我正在寻找指定文件(或文件目录)的元数据。我专门在 .WTV 文件上寻找“程序说明”。

我找到了代码,但它没有列出该属性。其中一些代码如下所示:

 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() 

我可以在文件资源管理器中看到该属性。

最佳答案

@user1921849 的代码几乎已经解决了,但是为了更清楚地解决原始问题,您应该使用 Windows Shell 属性系统命名属性,列在 Windows devloper documentation for WTV files 中。 , 并在下面的第 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')

更新了文档 URL

  1. 一般属性列表 https://learn.microsoft.com/en-us/windows/desktop/properties/props
  2. WTV 属性列表 https://learn.microsoft.com/en-us/windows/desktop/properties/recordedtv-bumper

关于Powershell获取文件的元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21420962/

相关文章:

c# - 在 C# 中运行 PowerShell cmdlet

python - 从 Python 执行 PowerShell 脚本的最佳方式是什么

PHP exif_read_data 不再提取 GPS 位置

memory - Hadoop Namenode 元数据 - fsimage 和编辑日志

c# - 通过元数据嵌入版本信息?

python - PyExifTool 是否有一种将元数据写入图像的方法?

powershell - 使用powershell生成日期并保存到批处理变量时如何设置日期格式?

powershell - 使用路径中的环境变量运行 EXE 文件(PowerShell)

Powershell v2 |脚本不会声明变量,需要帮助调试

clojure - 使用无点样式定义的文档函数