Fixed copy-photos-sorted.ps1

This commit is contained in:
Markus Fleschutz 2025-01-21 09:39:50 +01:00
parent 46235b0aa0
commit 6fda26dc5d

View File

@ -5,12 +5,12 @@
This PowerShell script copies image files from <sourceDir> to <targetDir> sorted by year and month. This PowerShell script copies image files from <sourceDir> to <targetDir> sorted by year and month.
.PARAMETER sourceDir .PARAMETER sourceDir
Specifies the path to the source folder Specifies the path to the source folder
.PARAMTER targetDir .PARAMETER targetDir
Specifies the path to the target folder Specifies the path to the target folder
.EXAMPLE .EXAMPLE
PS> ./copy-photos-sorted.ps1 D:\iPhone\DCIM C:\MyPhotos PS> ./copy-photos-sorted.ps1 D:\iPhone\DCIM C:\MyPhotos
Copying IMG_20240903_134445.jpg to C:\MyPhotos\2024\09 SEP\... Copying IMG_20240903_134445.jpg to C:\MyPhotos\2024\09 SEP\...
Copied 1 photo to 📂C:\MyPhotos (0 skipped) in 41s. Copied 1 photo to 📂C:\MyPhotos in 13s (0 skipped).
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -88,7 +88,7 @@ try {
} }
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds [int]$elapsed = $stopWatch.Elapsed.TotalSeconds
[int]$copied = $files.Count - $skipped [int]$copied = $files.Count - $skipped
"✅ Copied $copied photos to 📂$targetDir ($skipped skipped) in $($elapsed)s." "✅ Copied $copied photos to 📂$targetDir in $($elapsed)s ($skipped skipped)."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"