Fix Photo Timestamps in Bulk with PowerShell

Shift LastWriteTime/CreationTime on a whole folder of photos by any offset with DateTime arithmetic.

WindowsmetadataphotospowershellLow risk
Pipe Get-ChildItem into ForEach-Object and assign the offset with .AddHours() to the file's time properties.

01Command

Command
$ 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

RiskLow risk

04Undo

Undo
$ Repeat with a negative offset: ForEach-Object { $_.LastWriteTime = $_.LastWriteTime.AddHours(-7) }

05Sources

  • Set-ItemProperty (Microsoft.PowerShell.Management)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Shows setting file property values such as timestamps; direct assignment to FileInfo properties is equivalent PowerShell syntax.
  • FileSystemInfo.LastWriteTime Property
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents that LastWriteTime, CreationTime and LastAccessTime on file info objects are settable DateTime properties.

Last verified: 2026-09-17 · Category: Media

06Related solutions