Created
July 11, 2022 16:56
-
-
Save toksikk/5a37845697b02c0b2e412ec03d0cee4d to your computer and use it in GitHub Desktop.
I had a tool that did not write EXIF data to jpg files so I wrote this small Powershell script to use the file names that were conveniently creation dates in unix millisecond timestamps.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName System.Drawing | |
$imageSourcePath = Get-Location | |
$files = Get-ChildItem -Path $imageSourcePath -filter *.jpg | |
$numFiles = $files.Count | |
[Int32]$counter = 0 | |
foreach ($file in $files) { | |
$takenDateUNIXMilli = $file.BaseName | |
$takenDate = ((Get-Date 01.01.1970) + ([System.TimeSpan]::frommilliseconds($takenDateUNIXMilli))) | |
$counter++ | |
Write-Progress "$numFiles image files." -PercentComplete (100 * $counter / $numFiles) | |
$file.CreationTime = $takenDate | |
$file.LastWriteTime = $takenDate | |
} | |
Write-Output "Fixed CreationTime and LastWriteTime for $numFiles files from $imageSourcePath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment