From filename into datestamp?

I rename my photos with the original datetime stamp (YYYYMMDD_HHMMSS.jpg). This is so that if I edit and resave, I can keep track of the original time the photo was taken. Also helps with organizing them. I find the Creation Date is not very reliable, some programs seem to reset this.

Recently I bought a digital frame that can display the file datestamp as a text overlay. To work with this, I would like to parse the datetime in each filename, then use this to reset the Modified Date.

Anyone know if this possible, maybe with Python, or maybe a cmd-line utility?

Thanks for any ideas!

so essentially you want to change the modified date to be equal to the filename?

so,

20110101_120101.jpg would change the modified date property to 01/01/2011?

if that’s what your thinking, I think you would have to change the date on the computer to whatever date, then modify it somehow. I’m not sure this is possible within pythons file object. might be the systems job. cmd might be usable? i dono, without looking into it.

Thanks Shawn.

I think I found a standalone that does it, though in German. :wink:
http://members.kabsi.at/Oberreiter/EXIFDatum/exifdatum_en.htm

On closer inspection it seems my digital frame uses the EXIF date, not the file date.

Some of my files predate digital cameras, so they were scanned in, and thus have inaccurate file dates. Thus the filenames are more accurate.

for future use.

If you would still like to roll your own, here’s the extract-time-from-filename part in Python.

 
>>> import datetime
>>> filename = '20111226_072130.jpg'
>>> datetime.datetime.strptime( filename, '%Y%m%d_%H%M%S.jpg' )
datetime.datetime(2011, 12, 26, 7, 21, 30)

Thanks gentlemen!