Update copy-photos-sorted.ps1

This commit is contained in:
Markus Fleschutz 2023-01-07 18:10:31 +01:00
parent 5d74055659
commit f7d812618b

View File

@ -36,9 +36,9 @@ function CopyFile { param([string]$SourcePath, [string]$TargetDir, [int]$Date, [
} }
$TargetPath = "$TargetDir/$Year/$MonthDir/$Filename" $TargetPath = "$TargetDir/$Year/$MonthDir/$Filename"
if (Test-Path "$TargetPath" -pathType leaf) { if (Test-Path "$TargetPath" -pathType leaf) {
"⏳ Skipping existing $($Filename)..." Write-Host "⏳ Skipping existing $Year/$MonthDir/$Filename..."
} else { } else {
"⏳ Copying $Filename to $Year/$MonthDir..." Write-Host "⏳ Copying $Filename to $Year/$MonthDir..."
New-Item -path "$TargetDir" -name "$Year" -itemType "directory" -force | out-null New-Item -path "$TargetDir" -name "$Year" -itemType "directory" -force | out-null
New-Item -path "$TargetDir/$Year" -name "$MonthDir" -itemType "directory" -force | out-null New-Item -path "$TargetDir/$Year" -name "$MonthDir" -itemType "directory" -force | out-null
Copy-Item "$SourcePath" "$TargetPath" -force Copy-Item "$SourcePath" "$TargetPath" -force
@ -75,7 +75,7 @@ try {
$Array = $Filename.split("_") $Array = $Filename.split("_")
CopyFile "$File" "$TargetDir" $Array[1] "$Filename" CopyFile "$File" "$TargetDir" $Array[1] "$Filename"
} else { } else {
"⏳ Skipping $Filename with unknown filename format..." Write-Host "⏳ Skipping $Filename with unknown filename format..."
} }
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds