Fix Photo Timestamps in Bulk with PowerShell
Shift LastWriteTime/CreationTime on a whole folder of photos by any offset with DateTime arithmetic.
01Command
$ Get-ChildItem 'C:\Users\me\Pictures\Camera' | ForEach-Object { $_.LastWriteTime = $_.LastWriteTime.AddHours(7); $_.CreationTime = $_.CreationTime.AddHours(7) }02What it does
Photos from a device with the wrong clock sort wrong in every gallery app, and fixing them one by one in Explorer is painful. FileInfo's CreationTime, LastWriteTime and LastAccessTime are writable DateTime properties, and .AddHours/.AddDays make the shift a one-liner. Note this changes the filesystem timestamps — the EXIF 'Date Taken' baked into the JPEG itself is untouched and would need a metadata library to edit.
03Risk
04Undo
$ Repeat with a negative offset: ForEach-Object { $_.LastWriteTime = $_.LastWriteTime.AddHours(-7) }05Sources
- Set-ItemProperty (Microsoft.PowerShell.Management)Evidence: Shows setting file property values such as timestamps; direct assignment to FileInfo properties is equivalent PowerShell syntax.
- FileSystemInfo.LastWriteTime PropertyEvidence: Documents that LastWriteTime, CreationTime and LastAccessTime on file info objects are settable DateTime properties.
Last verified: 2026-09-17 · Category: Media
06Related solutions
Search inside text files and logs with regex, returning file, line number and match.
Create or update a .zip from any files or folder contents straight from PowerShell.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.