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 = ""
#$DestinName = "真の仲間"
#$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 $_})
$WorkData = $(if (Test-Path "$JsonPath\animelibk.json") {
Get-Content "$JsonPath\animelibk.json" | ConvertFrom-Json
@ -22,7 +23,7 @@ if (-not($WorkData.TargetName)) {
$WorkData.TargetName = $($JsonPath -replace '.*\\[0-9\s]*(.*)$', '$1');
}
if (-not($WorkData.DestinName)) {
$WorkData.DestinName = Read-Host "請輸入目的名稱:";
$WorkData.DestinName = Read-Host "請輸入目的名稱:";
}
if (-not($WorkData.Season)) {
[int] $WorkData.Season = Read-Host "請輸入季別:";
@ -33,14 +34,18 @@ if (-not($WorkData.Episode)) {
$WorkData
$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])*")) {
# mkdir -p ".\$DestinName\$($Seasons_TC[$Season]) ($Year)"
#} else {
# Get-Item -Path ".\$DestinName\$($Seasons_TC[$Season])*"
#})
$LinkPath = ".\{0}\{1}" -f $WorkData.DestinName, $Seasons_TC[$WorkData.Season]
$LinkDir = $(if (-not(Test-Path -Path "$LinkPath*")) {
New-Item -Path "$LinkPath ($Year)" -ItemType Directory -Force
} else {
Get-Item -Path "$LinkPath*"
})
#$DestDir = $(New-Item -Path ".\$WorkData.DestinName\$($Seasons_TC[$WorkData.Season]) ($Year)" -ItemType Directory -Force)
function Get-StandName {
@ -106,7 +111,8 @@ $NewNameObj = @{
}
$StructPathObj = @{
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 ###
@ -141,8 +147,8 @@ exit 0;
# SIG # Begin signature block
# MIIFxwYJKoZIhvcNAQcCoIIFuDCCBbQCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUuwJuleFHAYU44/Bdnmy+R8Lg
# /zKgggNSMIIDTjCCAjagAwIBAgIQdMnAQ4BDAo9Lgfn+QeDdhjANBgkqhkiG9w0B
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU3YLRpMFGrmg+Su+5oeIKvraA
# BeGgggNSMIIDTjCCAjagAwIBAgIQdMnAQ4BDAo9Lgfn+QeDdhjANBgkqhkiG9w0B
# AQUFADAqMRMwEQYDVQQDDApOaW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