Update copy-photos-sorted.ps1

This commit is contained in:
Markus Fleschutz 2022-11-14 20:14:51 +01:00
parent d645f5940d
commit bf5aa0a598

View File

@ -36,7 +36,7 @@ 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 $Filename: already existing..." "Skipping $($Filename): already existing..."
} else { } else {
"Copying $Filename to $Year/$MonthDir..." "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
@ -70,7 +70,7 @@ try {
$Array = $Filename.split("_") $Array = $Filename.split("_")
CopyFile "$File" "$TargetDir" $Array[1] "$Filename" CopyFile "$File" "$TargetDir" $Array[1] "$Filename"
} else { } else {
"Skipping $Filename: unknown filename format..." "Skipping $($Filename): unknown filename format..."
} }
} }