Fix Photo File Dates on Android with adb
Set the file date of photos on an Android phone from a computer with adb and touch, so the gallery puts screenshots, chat images and copied photos back on the right day.
To fix the file date of a photo on Android, connect the phone with USB debugging on and run adb shell touch -m -d "2019-07-14 11:05:00" "/sdcard/DCIM/Camera/photo.jpg". Then ask the gallery to look again with adb shell content call --uri content://media/ --method scan_volume --arg external_primary. The gallery uses the file date for every photo without a date taken inside, so this puts those photos back on their real day.
When this is the right fix
The gallery sorts by the date taken inside a photo. Only when there is none does it use the file date. So this matters for:
- screenshots and screen recordings
- images from WhatsApp, Telegram and other chats
- photos copied to the phone with "File transfer", which got today as their file date
- photos restored from a backup app that did not keep dates
If a photo has a wrong date taken inside, changing the file date does not help. Change the date taken instead: how to change the date of a photo on Android.
What you need
- USB debugging on: how to turn on USB debugging
- Google's adb on the computer, from "SDK Platform-Tools"
- the phone connected and allowed;
adb devicesshows it asdevice
Look at the dates first
adb shell stat -c '%y %n' "/sdcard/DCIM/Screenshots/*"
Each line shows the file date and the name. A folder where every file has the same day, the day you copied it, is the one to fix.
Set one file's date
adb shell touch -c -m -d "2019-07-14 11:05:00" "/sdcard/DCIM/Screenshots/Screenshot_20190714-110500.png"
-m sets the modification date, which is the one the gallery reads. -c makes sure touch never creates an empty file when the name is mistyped. Without -c, a typo leaves a zero-byte file behind.
The time is read in the phone's time zone. If you prefer to be exact, use seconds since 1970 instead: -d @1563095100.
Many files: take the date from the name
Most phones and chat apps put the date in the file name: Screenshot_20190714-110500.png, IMG-20220925-WA0018.jpg, IMG_20220104_184121.jpg. A short script on the computer can turn those names into dates and write one touch line per file into a script, which the phone then runs in one go:
adb push dates.sh /data/local/tmp/
adb shell sh /data/local/tmp/dates.sh
adb shell rm /data/local/tmp/dates.sh
One script with thousands of lines runs in seconds. Thousands of separate adb commands take minutes.
Tell the gallery
adb shell content call --uri content://media/ --method scan_volume --arg external_primary
This asks Android's media scanner to read every file again, which takes a minute or two for a big phone. On Android 9 and older, use this for each file instead:
adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d "file:///sdcard/DCIM/Screenshots/photo.png"
Check
Run the stat command again, then open the gallery. The photos should now sit on their real days.
The same without a command line
Photo Date & Metadata Fixer's Android Phone tab, which is Windows only, does this for whole folders. Pick a folder on the phone, and the app reads each photo's date taken from the photo itself, then its name, then its file date, shows you what it would change, and sets the dates in one step. Every change can be undone.

Frequently asked questions
Does touch change the photo itself?
No. It changes the date the storage keeps for the file. The picture and its EXIF stay as they are.
Does it work on photos in Google Photos' cloud?
No. It works on files stored on the phone. For photos that only exist in Google Photos, change the date in the Google Photos app.
Can I set the creation date too?
Android's storage does not let you set a creation date. The modification date is the one gallery apps use.