您可以使用 Powershell 设置视频的详细信息吗?

Can you set Details for Videos with Powershell?

我有一台 NAS,我将大部分 DVD 翻录到该 NAS 上。问题来自系列。当我必须对某个季节进行 RIP 处理时,必须手动输入详细信息(标题、评论等)。

为了解决这个问题,我编写了以下脚本:

$array = @() 
(Get-ChildItem -Path 'c:\Videos\Dead Like Me\*.mpg' ).FullName |
foreach{
   $array += $_ 
   }
$i = 0
Do  {
    $Episode = $i + 1
    $NewName = "Dead Like Me S1E$Episode.mpg"
    Set-ItemProperty -Path $array[$i] -Name "Title" -Value $NewName
    Set-ItemProperty -Path $array[$i] -Name "Comments" -Value $NewName
    Rename-Item -Path $array[$i] -NewName $NewName
$i += 1
} While ($i -lt $array.length)

似乎 Set-ItemProperty 无法识别文件的标题和注释,也无法识别文件 "Details" 选项卡中的其他属性。

我也试过了

Get-ChildItem $array[$i] | Set-ItemProperty -Name "Title" -Value $NewName

无论哪种方式,我都会收到类似于以下内容的错误:

Set-ItemProperty : The property string Title=Dead Like Me S1 D1 E3.mpg does not exist or was not found. At c:\Videos\Dead Like Me\tmp.ps1:20 char:30 + ... ChildItem $array[$i] | Set-ItemProperty -Name "Title" -Value $NewName + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ReadError: (string Title=Dead Like Me S1 D1 E3.mpg:PSNoteProperty) [Set-ItemProperty], I OException + FullyQualifiedErrorId : SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand

Set-ItemProperty 不应该能够处理这些属性吗?

@trebleCode 更新

我运行以下:

get-itemproperty "C:\Videos\Dead Like Me\video.mpg" | Format-List -Property * -Force

它returns:

 PSPath            : Microsoft.PowerShell.Core\FileSystem::C:\Video\Dead Like Me\video.mpg 
 PSParentPath      : Microsoft.PowerShell.Core\FileSystem::C:\Video\Dead Like Me Renamer 
 PSChildName       : video.mpg 
 PSDrive           : C 
 PSProvider        : Microsoft.PowerShell.Core\FileSystem Mode              : -a----
 VersionInfo       : 
                     File: C:\Video\Dead Like Me\video.mpg
                     InternalName:
                     OriginalFilename:
                     FileVersion:
                     FileDescription:
                     Product:
                     ProductVersion:
                     Debug:            False
                     Patched:          False
                     PreRelease:       False
                     PrivateBuild:     False
                     SpecialBuild:     False
                     Language:

 BaseName          : video 
 Target            : {} 
 LinkType          :
 Name              : video.mpg 
 Length            : 321536 
 DirectoryName     : C:\Video\Dead Like Me 
 Directory         : C:\Video\Dead Like Me 
 IsReadOnly        : False 
 Exists            : True 
 FullName          : C:\Video\Dead Like Me\video.mpg
 Extension         : .mpg 
 CreationTime      : 2019-02-04 10:15:51
 CreationTimeUtc   : 2019-02-04 16:15:51 
 LastAccessTime    : 2019-02-04 13:03:31 
 LastAccessTimeUtc : 2019-02-04 19:03:31 
 LastWriteTime     : 2018-07-09 15:00:47 
 LastWriteTimeUtc  : 2018-07-09 20:00:47 
 Attributes        : Archive

有一个名为 TagLib-Sharp that supports setting metadata on audio and video files. It's pretty easy to use - there's some sample code at this blog 的开源库 - 它的要点是:

Import-Module "D:\powershell\modules\MPTag\taglib-sharp.dll"
$BOXTYPE_TVSH = "tvsh"; # TV Show or series
$mediaFile = [TagLib.File]::Create($file.FullName)
[TagLib.Mpeg4.AppleTag]$customTag = $mediaFile.GetTag([TagLib.TagTypes]::Apple, 1)
$customTag.SetText($BOXTYPE_TVSH, $showName)
$mediaFile.Save()