I'm trying to get the filename of a screenshot on an Android phone (which contains the date it was taken) as a string and add it to the Exif timestamp of that screenshot (which doesn't seem to have been recorded when those screenshots were taken).

All the filenames of these photos follows the same template: Screenshot_YYYYMMDD-******.png.

Is there a way to achieve this?

  • 1
    There is no EXIF in a PNG image, that's why you can't find one. – xhienne Sep 16 '17 at 20:27
  • It's not a standard, but of course you can store EXIF-metadata into a PNG-File. It won't be recognized by all programs, as the standardization wasn't successfull. See this answer – Stefan M Sep 16 '17 at 20:32

Yes there is, use exiftool. Under Debian/Ubuntu this can be installed with

sudo apt install libimage-exiftool-perl

Something like this should work (assuming the *** show the time):

exiftool "-datetimeoriginal<filename" Screenshot_YYYYMMDD-HHMMSS.png

exiftool detects the dateformat on its own, you can look at the current EXIF metadata (and some more by simply calling the tool with the filename:

exiftool Screenshot_YYYYMMDD-HHMMSS.png

If you have a filename which can't be automatically read by exiftool, you can use the -d Parameter to clear things up for exiftool. Again, for your example:

exiftool "-datetimeoriginal<filename" -d Screenshot_%Y%m%d-%H%M%S Screenshot_YYYYMMDD-HHMMSS.png

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.