From d3bdbdf02d0a9eaf921cd8fe3ade2639ff580ad5 Mon Sep 17 00:00:00 2001 From: jvlflame Date: Fri, 25 Dec 2020 18:09:47 -0800 Subject: [PATCH] Trim erroneous trailing dots on directory paths (#168) --- src/Javinizer/Public/Set-JVMovie.ps1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Javinizer/Public/Set-JVMovie.ps1 b/src/Javinizer/Public/Set-JVMovie.ps1 index b8b0e33c..c96fe773 100644 --- a/src/Javinizer/Public/Set-JVMovie.ps1 +++ b/src/Javinizer/Public/Set-JVMovie.ps1 @@ -235,6 +235,9 @@ function Set-JVMovie { } if ($Force -or $PSCmdlet.ShouldProcess($Path)) { + # Windows directory paths do not allow trailing dots/periods but do not throw an error on creation + $folderPath = $folderPath.TrimEnd('.') + # We do not want to recreate the destination folder if it already exists try { if (!(Test-Path -LiteralPath $folderPath) -and (!($Update))) { @@ -469,13 +472,13 @@ function Set-JVMovie { } elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') { if ($Force) { try { - mv $Path $filePath --force + Move-Item $Path $filePath --force } catch { Move-Item -LiteralPath $Path -Destination $filePath -Force } } else { try { - mv $Path $filePath --no-clobber + Move-Item $Path $filePath --no-clobber } catch { Move-Item -LiteralPath $Path -Destination $filePath } @@ -504,13 +507,13 @@ function Set-JVMovie { } elseif ([System.Environment]::OSVersion.Platform -eq 'Unix') { if ($Force) { try { - mv $Path $filePath --force + Move-Item $Path $filePath --force } catch { Move-Item -LiteralPath $Path -Destination $filePath -Force } } else { try { - mv $Path $filePath --no-clobber + Move-Item $Path $filePath --no-clobber } catch { Move-Item -LiteralPath $Path -Destination $filePath }