我有一个NAS到我撕裂了我大部分的DVD。这个问题是与系列。当我有翻录季节,详细信息(标题,注释等)必须手动输入。
为了解决这个问题,我写了下面的脚本:
$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)
如此看来,集-ItemProperty不会从该文件的“详细资料”标签识别名称,也不评论,而不是其他的属性。
我也试着
Get-ChildItem $array[$i] | Set-ItemProperty -Name "Title" -Value $NewName
无论哪种方式,我得到类似如下的错误:
SET-ItemProperty:属性字符串标题=死像我这样的S1 D1 E3.mpg不存在或没有被发现。在C:\视频\死像我这样的\ tmp.ps1:20字符:30 + ... ChildItem $阵列[$ i] | SET-ItemProperty -Name “标题” 值$新名称+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ + CategoryInfo:ReadError:(字符串名称=死像我S1 D1 E3.mpg:PSNoteProperty)[设置ItemProperty],我OException + FullyQualifiedErrorId:SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand
不应设置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一个开放源码库,支持音频和视频文件设置的元数据。这是很容易使用 - 有一些示例代码在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()