powershell - 您可以使用 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 无法识别标题或评论,而不是文件“详细信息”选项卡中的其他属性。
我也试过
Get-ChildItem $array[$i] | Set-ItemProperty -Name "Title" -Value $NewName
无论哪种方式,我都会收到类似于以下内容的错误:
Set-ItemProperty:属性字符串 Title=Dead Like Me S1 D1 E3.mpg 不存在或找不到。在 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
它返回:
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的开源库,它支持在音频和视频文件上设置元数据。它很容易使用——这个博客上有一些示例代码——它的要点是:
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()
推荐阅读
- google-kubernetes-engine - 如何使用 kong k8 入口公开 kong admin api?
- xml - jaxb2:忽略注释
- database - 根据 quintity 去除重复数据
- entity-framework - 实体框架糟糕的加入
- python - 如何使用 Selenium 修改 python 代码?
- java - 如何使用设备客户端或一些 Http 请求在 Azure IoT 中心 ping 设备预配服务
- assembly - cmpeqpd 有时会返回错误的值
- shell - 分配 * 时我无法获得所需的输出
- python - 无法将 seaborn 导入 Jupyter 笔记本
- javascript - 如何在我的自定义 React 钩子中编写条件逻辑