@ -3,7 +3,7 @@
$Index = " H:\AnimeLib " ,
$VarConfig ,
$RecorDB = " animelibk.ini " ,
$Include = @ ( " .rmvb " , " .mp4 " , " .mkv " , " .ass " , " .ssa " ) ,
$Include = @ ( " .rmvb " , " .mp4 " , " .mkv " , " .avi " , " .a ss " , " .ssa " ) ,
[switch] $Single ,
[switch] $Force ,
[switch] $Sub ,
@ -57,14 +57,14 @@ if ($VarConfig) {
#$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"
$JsonPath = $ ( " $ Index\Anime\* $ TargetName " , $ ( $Path -replace '(.*\\[^\[\\\]]*)\\\[.*' , '$1' ) | ? { Test-Path $_ } )
$JsonPath = " $ Index\Anime\* $ TargetName " , $ ( $Path -replace '(.*\\[^\[\\\]]*)\\\[.*' , '$1' ) | ? { Test-Path $_ }
if ( $RecorDB -notmatch " : " ) { $RecorDB = " $ JsonPath\ $ RecorDB " }
$WorkData = $ ( if ( Test-Path $RecorDB ) {
Get-Content $RecorDB | ConvertFrom-Json
} else {
" " | Select-Object ID , WorkName , TargetName , DestinName , Season , Episode
} )
if ( $RecorDB -notmatch " : " ) { $RecorDB = " $ JsonPath\ $ RecorDB " }
$RecorDB
# 確認資料狀態,缺少則進行物件資料建立
if ( -not ( $WorkData . WorkName ) ) {
@ -91,8 +91,20 @@ $Lang = @{
}
$Year = @ ( $ ( $JsonPath -replace '.*\\((?<Y>\d{4})?(?<M>\d{2})?).*$' , '${Y}' ) , $ ( get-date -Format 'yyyy' ) ) | ? { -not ( [string] :: IsNullOrEmpty ( $_ ) ) } | Select -First 1
# 依目標檔案位置變更磁碟代號
$TargetDrive = Split-Path -Path $JsonPath -Qualifier
if ( Split-Path -Path $Index -IsAbsolute ) {
if ( $Index -notmatch $TargetDrive ) {
$Index2 = Join-Path -Path $TargetDrive -ChildPath ( Split-Path -Path $Index -noQualifier )
} else {
$Index2 = $Index
}
} else {
$Index2 = Join-Path $TargetDrive $Index
}
Write-Host $Index2
# 取得目標資料夾是否存在,不存在建立資料夾,並取得資料夾物件
$LinkPath = " {2}\{0}\{1} " -f $WorkData . DestinName , $ ( $Lang [ " Season " ] -f $WorkData . Season ) , $Index
$LinkPath = " {2}\{0}\{1} " -f $WorkData . DestinName , $ ( $Lang [ " Season " ] -f $WorkData . Season ) , $Index2
$LinkDir = $ ( if ( -not ( Test-Path -Path " $ LinkPath* " ) ) {
New-Item -Path " $ LinkPath ( $ Year) " -ItemType Directory -Force
} else {
@ -149,7 +161,7 @@ if ($Single) {
# 單集模式
$List = @ ( Get-Item -Path $ ( Edit-PathChar $Path ) )
$BuildList = $List | select $FileObj , $StructPathObj , $NewNameObj | ? { $_ . NewName . Episode -notin $WorkData . Episode }
#$BuildList | ? {$_.NewName.Episode -notin $WorkData.Episode} | Format-List
#$BuildList | ? {$_.NewName.Episode -notin $WorkData.Episode} | Format-List
} elseif ( $Sub ) {
$List = @ ( Get-Item -Path $ ( Edit-PathChar $Path ) )
$BuildList = $List | select $FileObj , $StructPathObj , $NewNameObj | ? { $_ . File . Extension -in @ ( " .ass " , " .ssa " ) }
@ -167,7 +179,7 @@ $ENDResult = $BuildList | % {
$Command = @ {
ItemType = 'HardLink'
Path = $ ( " {0}\{1} " -f $_ . StructPath , $_ . NewName . newFullName )
Target = $ ( Edit-PathChar $_ . File . Fullname )
Target = $ ( Edit-PathChar $_ . File . Fullname -nowlid )
}
#try {
if ( New-Item @Command ) {
@ -181,4 +193,4 @@ $ENDResult = $BuildList | % {
#$ENDResult.gettype();
if ( -not ( $Sub ) ) { $ENDResult | % { if ( $_ . Episode ) { $WorkData . Episode + = $_ . Episode } } }
$WorkData | ConvertTo-Json | Out-File -Encoding " UTF8 " $RecorDB
exit 0 ;
exit 0 ;