Yesterday, I moved a bunch of old pictures and videos to my phone, using a FTP server I installed on my phone. Everything went fine, but today I discovered that the date of all the copied photos and videos was set to yesterday. As a result, my photos and videos are now showing up in the wrong order in the Gallery app.

(Click image to enlarge)

IMG: screenshot

Luckily, the date and time is still preserved in the filenames. Right now, I want to restore the photos' and videos' date using their filenames.

I'm interested in a way to do so. I don't really care whether it's by using an app or script or something else.

I'm aware of the fact that I can copy the files from my computer to the phone again using a different protocol, but that is not what I'm looking for.

4 Answers 4


I ended up writing a rather dirty script to do this. For this to work, I'm assuming you have a rooted device, and the directory that contains the pictures and videos is /sdcard/DCIM/Camera. If otherwise, change the script.

  1. Download BusyBox and install it. This is needed for executing Linux shell commands.

  2. Create a script called script.sh, containing this block of code, and put it on the root of your sd card.

    cd DCIM/Camera
    echo "Navigated to `pwd`"
    for f in *.jpg *.3gp *.m4v
      [ -e $f ] || continue    ## testing if the file exists
      NEWDATE=`echo $f | sed 's|IMG_||g' | sed 's|VID_||g' | sed 's|_||g' | \
      sed 's|.3gp||g'  | sed 's|.m4v||g' | sed 's|.jpg||g' | sed 's|........|&\.|g'`
      echo "Touching date $NEWDATE into $f..."
      touch -t "$NEWDATE" "$f" ## using touch to insert the new date into the file
  3. Start adb shell, and execute:

    mount -o remount rw /sdcard

    to make sure you can actually edit the files

  4. Move to your sd card:

    cd /sdcard
  5. Execute the shell script:

    sh script.sh
  6. Now start the Gallery app, and wait. Especially if you have a large file collection, it may take Android a while to sort everything and update the cache.


If the EXIF data is correct, you can use jhead. Note that this only works for JPEG files.

First, check if the files still have correct EXIF data using:

jhead <file>

Then use jhead's -ft option:

-ft Sets the file's system time stamp to what is stored in the Exif header.

jhead *.jpg
  • Sounds good, but is there a binary for Android anywhere? Nov 18, 2018 at 12:16

You can easily change timestamp of images with many image viewers. For example in FastStone Viewer: Tools -> Change Timestamp -> choose the creation date from EXIF. You can select all your images before and apply this function on all of them at once.

My only idea about videos is a script, that parses a name and sets the file attribute.

  • Do you know any app that can do that directly on android? Ty.
    – Starlays
    Nov 30, 2017 at 14:36

This is an app you can make yourself, or I can do it for you if you so wish. It involves file manipulation using the Java File API or Unix shell tools, whichever you prefer. I think that if you have any programming experience at all the Java API documentation is a good place to start. Or, if you have Windows, you can use an extension to Windows explorer called QTTabbar (qttabbar.sourceforge.net) which has an option to copy files while preserving the last modified date. I suggest copying the files from your computer to the phone using a USB cable.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .