diff --git a/Animelibk.ps1 b/Animelibk.ps1 index 40b27be..b16681e 100644 --- a/Animelibk.ps1 +++ b/Animelibk.ps1 @@ -91,8 +91,19 @@ $Lang = @{ } $Year = @($($JsonPath -replace '.*\\((?\d{4})?(?\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 -match $TargetDrive) { + $Index2 = Join-Path -Path $TargetDrive -ChildPath (Split-Path -Path $Index -noQualifier) + } else { + $Index2 = $Index + } +} else { + $Index2 = Join-Path $TargetDrive $Index +} # 取得目標資料夾是否存在,不存在建立資料夾,並取得資料夾物件 -$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 {