Browse Source

Anime Link Libary: modify folder name

* 修正資料夾結構命名問題
* 擷取路徑上年份,無則以當前年份
master
pcnick 3 years ago
parent
commit
c40ffbc86a
  1. 42
      Animelibk.ps1

42
Animelibk.ps1

@ -6,7 +6,8 @@
$TargetName = "" $TargetName = ""
#$DestinName = "真の仲間" #$DestinName = "真の仲間"
#$Path = "" #$Path = ""
#$Path = "H:\Data\Downloads\因為不是真正的夥伴而被逐出勇者隊伍\[Shin no Nakama][04][BIG5][1080P].mp4" #$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 = $("..\Anime\* $TargetName", $($Path -replace '(.*\\[^\[\\\]]*)\\\[.*', '$1') | ? {Test-Path $_}) $JsonPath = $("..\Anime\* $TargetName", $($Path -replace '(.*\\[^\[\\\]]*)\\\[.*', '$1') | ? {Test-Path $_})
$WorkData = $(if (Test-Path "$JsonPath\animelibk.json") { $WorkData = $(if (Test-Path "$JsonPath\animelibk.json") {
Get-Content "$JsonPath\animelibk.json" | ConvertFrom-Json Get-Content "$JsonPath\animelibk.json" | ConvertFrom-Json
@ -22,7 +23,7 @@ if (-not($WorkData.TargetName)) {
$WorkData.TargetName = $($JsonPath -replace '.*\\[0-9\s]*(.*)$', '$1'); $WorkData.TargetName = $($JsonPath -replace '.*\\[0-9\s]*(.*)$', '$1');
} }
if (-not($WorkData.DestinName)) { if (-not($WorkData.DestinName)) {
$WorkData.DestinName = Read-Host "請輸入目的名稱:"; $WorkData.DestinName = Read-Host "請輸入目的名稱:";
} }
if (-not($WorkData.Season)) { if (-not($WorkData.Season)) {
[int] $WorkData.Season = Read-Host "請輸入季別:"; [int] $WorkData.Season = Read-Host "請輸入季別:";
@ -33,14 +34,18 @@ if (-not($WorkData.Episode)) {
$WorkData $WorkData
$Seasons_TC = "", "第一季", "第二季", "第三季", "第四季", "第五季" $Seasons_TC = "", "第一季", "第二季", "第三季", "第四季", "第五季"
$Year = $(get-date -Format yyyy) $Year = @($($JsonPath -replace '.*\\((?<Y>\d{4})?(?<M>\d{2})?).*$', '${Y}'), $(get-date -Format 'yyyy')) | ? {-not([string]::IsNullOrEmpty($_))} | Select -First 1
#$($JsonPath -replace '.*\\((?<Y>\d{4})?(?<M>\d{2})?).*$', '${Y}');
# 取得目標資料夾是否存在,不存在建立資料夾,並取得資料夾物件 # 取得目標資料夾是否存在,不存在建立資料夾,並取得資料夾物件
#$DestDir = $(if ( -not(Test-Path -Path ".\$DestinName\$($Seasons_TC[$Season])*")) { $LinkPath = ".\{0}\{1}" -f $WorkData.DestinName, $Seasons_TC[$WorkData.Season]
# mkdir -p ".\$DestinName\$($Seasons_TC[$Season]) ($Year)" $LinkDir = $(if (-not(Test-Path -Path "$LinkPath*")) {
#} else { New-Item -Path "$LinkPath ($Year)" -ItemType Directory -Force
# Get-Item -Path ".\$DestinName\$($Seasons_TC[$Season])*" } else {
#}) Get-Item -Path "$LinkPath*"
})
#$DestDir = $(New-Item -Path ".\$WorkData.DestinName\$($Seasons_TC[$WorkData.Season]) ($Year)" -ItemType Directory -Force) #$DestDir = $(New-Item -Path ".\$WorkData.DestinName\$($Seasons_TC[$WorkData.Season]) ($Year)" -ItemType Directory -Force)
function Get-StandName { function Get-StandName {
@ -106,7 +111,8 @@ $NewNameObj = @{
} }
$StructPathObj = @{ $StructPathObj = @{
label = "StructPath"; label = "StructPath";
Expression = {$(New-Item -Path $(".\{0}\{1} ({2})" -f $WorkData.DestinName, $Seasons_TC[$WorkData.Season], $Year) -ItemType Directory -Force).FullName}; #Expression = {$(New-Item -Path $(".\{0}\{1} ({2})" -f $WorkData.DestinName, $Seasons_TC[$WorkData.Season], $Year) -ItemType Directory -Force).FullName};
Expression = {$LinkDir};
} }
### # Select Object Mode END ### ### # Select Object Mode END ###
@ -141,8 +147,8 @@ exit 0;
# SIG # Begin signature block # SIG # Begin signature block
# MIIFxwYJKoZIhvcNAQcCoIIFuDCCBbQCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # MIIFxwYJKoZIhvcNAQcCoIIFuDCCBbQCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUuwJuleFHAYU44/Bdnmy+R8Lg # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU3YLRpMFGrmg+Su+5oeIKvraA
# /zKgggNSMIIDTjCCAjagAwIBAgIQdMnAQ4BDAo9Lgfn+QeDdhjANBgkqhkiG9w0B # BeGgggNSMIIDTjCCAjagAwIBAgIQdMnAQ4BDAo9Lgfn+QeDdhjANBgkqhkiG9w0B
# AQUFADAqMRMwEQYDVQQDDApOaWNrIENoYW5nMRMwEQYDVQQKDAplYXJpY2sub3Jn # AQUFADAqMRMwEQYDVQQDDApOaWNrIENoYW5nMRMwEQYDVQQKDAplYXJpY2sub3Jn
# MB4XDTIxMTAzMTEwMDI1MVoXDTIyMTAzMTEwMjI1MVowMzEiMCAGCSqGSIb3DQEJ # MB4XDTIxMTAzMTEwMDI1MVoXDTIyMTAzMTEwMjI1MVowMzEiMCAGCSqGSIb3DQEJ
# ARYTcGNuaWNrMTAwQGdtYWlsLmNvbTENMAsGA1UEAwwETmljazCCASIwDQYJKoZI # ARYTcGNuaWNrMTAwQGdtYWlsLmNvbTENMAsGA1UEAwwETmljazCCASIwDQYJKoZI
@ -163,11 +169,11 @@ exit 0;
# AgEBMD4wKjETMBEGA1UEAwwKTmljayBDaGFuZzETMBEGA1UECgwKZWFyaWNrLm9y # AgEBMD4wKjET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H2MFCGMl76oi5TTyeGdX2sdEEMyCNnEvrefl5V7KGCQfT
# hgqBiWBSbHgWkiKOwa6v3hdrEO9z+2strZn7OhNrnVCHq4A1mt96BzBo6A== # 82RApctXlL8jBfkqwte9cx3QebnIP97A6YmpS7ADIx1iqKOu0fC+RsIf4g==
# SIG # End signature block # SIG # End signature block

Loading…
Cancel
Save