@ -1,12 +1,17 @@
param (
$Path ,
$Index = " H:\AnimeLib " ,
[switch] $Single
[switch] $Single ,
[switch] $Force ,
[switch] $Sub
)
#$TargetName = "俺だけ入れる隠しダンジョン〜こっそり鍛えて世界最強〜";
$TargetName = " "
#$DestinName = "真の仲間"
Write-Output $Path
#$Index = "L:\AnimeLib"
#$Path = "L:\Anime\202001 ネコぱら\[Nekomoe kissaten][Nekopara][01-12][BDRip][1080p][CHT]\[Nekomoe kissaten][Nekopara][12][1080p][CHT].mp4"
#$Path = "L:\Anime\202004 ストライク・ザ・ブラッド OVA IV\[Suzu-Kaze][Strike_the_Blood_IV_OVA][01-12FIN][BDRip_1080P][HEVC_YUV420P10]\[Suzu-Kaze] Strike the Blood IV 12FIN [BDRip 1920x1080 HEVC YUV420P10 FLAC].mkv"
#$Path = "H:\Anime\201901 盾の勇者の成り上がり\[LKSUB][Tate no Yuusha no Nariagari][01-25][GB][720P][MP4]\[LKSUB][Tate no Yuusha no Nariagari][01][GB][720P].mp4"
#$Path = "H:\Data\Downloads\因為不是真正的夥伴而被逐出勇者隊伍\[Shin no Nakama][01][BIG5][1080P].mp4"
$JsonPath = $ ( " $ Index\Anime\* $ TargetName " , $ ( $Path -replace '(.*\\[^\[\\\]]*)\\\[.*' , '$1' ) | ? { Test-Path $_ } )
@ -62,8 +67,10 @@ function Get-StandName {
# 因應檔名不同而設定多組正規方式
$Result = @ ( $ (
#$($TestName[-1] -match "\[([^\]]*)\]\[(\d{1,2})\]")
#$($File.Name -match "[\[\s]([^\]]*?)(?:[\]\[\-\s]+)(\d{1,2})[\]\s]")
$ ( $File . Name -match " [\[\s](?<Name>\b[^\]]*\b)(?:[\]\[\-\s]+)(?<Episode>\d{1,2})(?:[vV]\d|FIN|END)?[\]\s] " )
#$($TestName[-1] -match "[\[\s](?<Name>[^\]]*?)(?:[\]\[\-\s]+)(?<Episode>\d{1,2})(?:[vV]\d)?[\]\s]")
) | % { if ( $_ ) { $Matches } } )
# 檔名分析測試用
@ -94,7 +101,7 @@ function Get-StandName {
$OutputData . newName = $Result . Name ;
$OutputData . Season = $WorkData . Season ;
$OutputData . Episode = [int] $Result . Episode ;
$OutputData . newFullName = " {0} S{3:00}E{1}{2} " -f $Result . Name , $Result . Episode , $File . Extension , $WorkData . Season ;
$OutputData . newFullName = " {0} S{3:00}E{1}{4}{ 2} " -f $Result . Name , $Result . Episode , $File . Extension , $WorkData . Season , $ ( if ( $Sub ) { " .default " } ) ;
#$OutputData | ConvertTo-Json;
# Type 2,在輸出顯示上,此型態建立較傾向 Hash,而上面 select 建立的,較偏向 pscustomobject
@ -140,6 +147,9 @@ if ($Single) {
$List = @ ( Get-Item -Path $ ( $Path -replace '([\[\]])' , '`$1' ) )
$BuildList = $List | select $FileObj , $StructPathObj , $NewNameObj | ? { $_ . NewName . Episode -notin $WorkData . Episode }
#$BuildList | ? {$_.NewName.Episode -notin $WorkData.Episode} | Format-List
} elseif ( $Sub ) {
$List = @ ( Get-Item -Path $ ( $Path -replace '([\[\]])' , '`$1' ) )
$BuildList = $List | select $FileObj , $StructPathObj , $NewNameObj | ? { $_ . File . Extension -in @ ( " .ass " , " .ssa " ) }
}
$ENDResult = $BuildList | % {
@ -149,15 +159,16 @@ $ENDResult = $BuildList | % {
Target = $ ( $_ . File . Fullname -replace '([\[\]])' , '`$1' )
}
#try {
# 判斷 New-Item @Command 是否成功,將 NEWNAME 物件作為回傳值
if ( New-Item @Command ) { $_ . NewName }
if ( New-Item @Command ) {
Write-Host $_ . NewName . newFullName
$_ . NewName }
#} catch {
#}
}
#$ENDResult
#$ENDResult.gettype();
$ENDResult | % { if ( $_ . Episode ) { $WorkData . Episode + = $_ . Episode } }
if ( -not ( $Sub ) ) { $ENDResult | % { if ( $_ . Episode ) { $WorkData . Episode + = $_ . Episode } } }
$WorkData | ConvertTo-Json | Out-File -Encoding " UTF8 " " $ JsonPath\animelibk.json "
exit 0 ;
@ -165,8 +176,8 @@ exit 0;
# SIG # Begin signature block
# MIIFxwYJKoZI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