Rename photos by the date they were taken on Windows, with a preview and undo
Two cameras, one trip, names out of order. How to name photos by the moment they were shot, see every new name first, and keep a way back.
We make Batch File Renamer, the app this guide uses. The free methods come first; every step shown in Batch File Renamer was checked in the app itself, and the screenshots come from the real app with invented sample data.
Short answer
Use the date taken stored inside each photo, not the date modified, which changes when an app saves the file again, after an edit for example. Windows PowerShell can read that date, show the new names first, rename the photos with a log and put the old names back from it: we ran the lines below on Windows 11. Batch File Renamer does the same in a window, numbers the photos in the order they were taken, flags clashing names before anything changes, and keeps a history to undo a batch.
Date taken, not date modified
Cameras and phones write the moment of the shot into the photo itself, in its EXIF data; Windows shows it as Date taken. The date modified belongs to the file and changes when an app saves it again, for example after an edit; it is not the moment of the shot. In our test, five invented photos, named and dated as if from two cameras and made for this guide in a folder called Rome 2026, all had 30 November 2026, the day we made them, as their date modified, while their dates taken ran from 14 to 16 July 2026. Their names did not help either: IMG_4031 and DSC_0007 follow each camera's own counter, not the time of the shot.
Method 1 (free): PowerShell, with a preview, a log and an undo
Windows PowerShell 5.1, which comes with Windows 10 and 11, can read the date taken: it is the EXIF tag 0x9003, listed in Microsoft's documentation of the PropertyItem.Id property, and stored as text in the form YYYY:MM:DD HH:MM:SS according to the property item descriptions. We ran the lines below on 30 November 2026 (Windows PowerShell 5.1, Windows 11) in one PowerShell window, from the folder that holds the photos. First a preview, which changes nothing:
Add-Type -AssemblyName System.Drawing
$plan = foreach ($f in Get-ChildItem -Filter *.jpg) {
$raw = $null; $img = $null; $taken = [datetime]::MinValue
try { $img = [System.Drawing.Image]::FromFile($f.FullName); $raw = $img.GetPropertyItem(0x9003).Value } catch {} finally { if ($img) { $img.Dispose() } }
$text = if ($raw) { [Text.Encoding]::ASCII.GetString($raw).Trim([char]0) } else { '' }
if (-not [datetime]::TryParseExact($text, 'yyyy:MM:dd HH:mm:ss', [cultureinfo]::InvariantCulture, 'None', [ref]$taken)) {
Write-Warning "$($f.Name): no readable date taken, left as it is"; continue
}
[pscustomobject]@{ Old = $f.Name; New = $taken.ToString('yyyy-MM-dd HHmmss') + $f.Extension.ToLower() }
}
$plan | Sort-Object New | Format-Table -AutoSize
$plan | Group-Object New | Where-Object Count -gt 1 | ForEach-Object { Write-Warning "$($_.Count) photos would be named $($_.Name)" }
Old New
--- ---
IMG_4031.JPG 2026-07-14 091203.jpg
DSC_0007.JPG 2026-07-14 132041.jpg
IMG_4032.JPG 2026-07-14 184207.jpg
IMG_4035.JPG 2026-07-15 100544.jpg
IMG_4100.JPG 2026-07-16 080000.jpg
Each new name is the date and time taken, to the second, so the two cameras' photos now sort in the order they were shot. No warning came up: no photo lacked a date taken, and no two would get the same name. If a warning names two photos taken in the same second, rename those by hand first or use the numbered names of Method 2. Then, in the same window, the renaming, with the old names saved in rename-log.csv first. The & { } around the lines makes PowerShell run them as one block, even when they are pasted into the window, so a clash stops the whole block before anything is written or renamed:
& {
if ($plan | Group-Object New | Where-Object Count -gt 1) { throw 'Two photos would get the same name: nothing renamed' }
$plan | Export-Csv -LiteralPath rename-log.csv -NoTypeInformation
foreach ($p in $plan) { Rename-Item -LiteralPath $p.Old -NewName $p.New }
"{0} photos renamed, old names in rename-log.csv" -f @($plan).Count
}
5 photos renamed, old names in rename-log.csv
To go back, this line, run from the same folder, gives each photo its old name from the log. We ran it after the renaming, and the five photos had their camera names again:
Import-Csv -LiteralPath rename-log.csv | ForEach-Object { Rename-Item -LiteralPath $_.New -NewName $_.Old }
The lines read .jpg files only (Windows matches .JPG too), so the folder's text file was left alone, and a photo without a readable date taken keeps its name, with a warning: in a second test folder, a photo with a blank date and a scan with none were both left as they were. Run the undo before you rename anything else in the folder. Keep rename-log.csv somewhere safe until you are sure: running the renaming again in the same folder replaces it, and the old camera names in it are then gone.
Other free tools: PowerRename and ExifTool
PowerRename, part of Microsoft PowerToys, has variables for the date taken, such as $DATE_TAKEN_YYYY and $DATE_TAKEN_MM, besides those for the file's creation date, with a preview and undo, according to Microsoft's documentation. ExifTool renames files from a date stored in them and has a dry run, -testname, that shows the new names first. Neither is installed on the PC used for this guide, so we did not run them.
Method 2: numbered names by date taken with Batch File Renamer
Batch File Renamer is our Windows app for renaming many files at once from building blocks: text, numbering, dates from the file or the photo, find and replace, and case changes. A preview shows every old and new name before anything changes, conflicts are flagged, and an undo log restores the previous names. It works offline. The screenshots below come from version 1.0.0 (evaluation build) with the same kind of invented sample: five photos from two cameras and a text file.
- Add the photos. Add files or Add folder, with Include subfolders if the photos are spread over several folders.
- Build the name. The line under the name field lists the blocks: {taken} is the date the photo was taken, {date} the date modified. With
Rome {taken}alone, the three photos from 14 July would get the same name: the list marks each of them "Conflict: 3 files would get this name", and only the three others would be renamed. - Add a number in date-taken order.
Rome {taken} {n:3}with Number in this order: Date taken gives Rome 2026-07-14 001.jpg to Rome 2026-07-16 005.jpg; set Extension to lower (.jpg) under Case and spaces for the lower-case extension. The text file, which has no date taken, got its date modified, 16 July, and number 006; Remove takes it out of the list if you do not want it renamed. - Save the settings as a preset, such as Holiday photos, for the next trip.
- Rename, and undo if needed. History lists each batch with every old and new name; Undo this batch gives each file its old name back, if it is still the same file.



Under the list, the app says that only names change: the files stay in their folders and are never overwritten. If the same folder holds resized copies of your photos, our guide to finding resized duplicate photos helps sort them out.
Limitations
- The PowerShell lines read .jpg files only (not .jpeg or HEIC), the only kind we ran them on; they leave a photo without a readable date taken as it is and stop if two photos would get the same name.
- A date taken is only as right as the camera's clock: two cameras set to different times sort out of order with any method.
- Batch File Renamer used the date modified for the text file, which has no date taken: check the preview for files like that. Its planned requirements: Windows 10 (22H2) or 11, 64-bit.
References
- Microsoft Learn: PowerRename utility for Windows
- ExifTool: Writing FileName and Directory tags
- Microsoft Learn: PropertyItem.Id property
- Microsoft Learn: Property item descriptions