You are not logged in.

#1 2010-06-23 00:43:56

victorhooi
Member
Registered: 2009-08-06
Posts: 109

Modify "date modified" on images to match "EXIF date"?

heya,

This isn't strictly a Arch Linux related question, but the community on here is fairly knowledgeable, and it's a scripting question smile.

I have a bunch of images in a directory, taken by my old BB 9700 phone.

The names of these are a bit mixed up, because BB's tend to randomly reset the increment counter - the files are named something like "IMG00001-20100216-1319", but I've got "IMG00001-20100418-1220", for example, as well.

When I browse these with Dolphin (KDE File Manager), I can choose to sort them by name, or by date. However, this is date modified, not the EXIF date. On Windows, Explorer lets you sort either by Date Modified, or by "Date Taken", which I assume is the EXIF date.

It's a bit annoying that Dolphin doesn't let you sort by EXIF date, but that's another issue. On my phone (Nexus One), the Android Gallery application also seems to sort by Date Modified, not the EXIF date.

My question is, is there any way to say, run "touch" on the files, and get the date modified to match the EXIF date? Any programs or scripts you know of that can do this?

Cheers,
Victor

Offline

#2 2010-06-23 01:29:40

kazuo
Member
From: São Paulo/Brazil
Registered: 2008-03-18
Posts: 413
Website

Re: Modify "date modified" on images to match "EXIF date"?

Well... you can write a quick 'n dirty script in you favorite language for example zsh+python+awk

$ for i in *.jpg; do touch -d "$(identify -verbose $i|awk '/exif:DateTimeOriginal:/ {print $2,$3}'|python -c 'from time import *;from sys import stdin; print strftime("%Y-%m-%d %H:%M:%S", strptime(stdin.read(), "%Y:%m:%d %H:%M:%S\n"))')" $i;done

(This works on bash+python+awk too, I think). This works for me because my photos have a exif filed with 'DateTimeOriginal' run identify -verbose in your images and select the correct field. My exif field have a format '%Y:%m:%d %H:%M:%S' if this is not your case change this.

EDIT For this simple date format case you can use only awk

for i in *.jpg; do touch -d "$(identify -verbose $i|awk '/exif:DateTimeOriginal:/ {print $2,$3}'|awk -F : '{printf("%s-%s-%s:%s:%s", $1,$2,$3,$4,$5)}')" $i;done

Last edited by kazuo (2010-06-23 01:36:28)

Offline

#3 2010-06-23 04:22:36

jwwolf
Member
Registered: 2009-06-29
Posts: 74

Re: Modify "date modified" on images to match "EXIF date"?

Or just use jhead and do this in the directory.

 jhead -ft *.jpg

DATE / TIME MANIPULATION:
  -ft        Set file modification time to Exif time

Last edited by jwwolf (2010-06-23 04:23:57)

Offline

#4 2010-06-23 04:51:24

victorhooi
Member
Registered: 2009-08-06
Posts: 109

Re: Modify "date modified" on images to match "EXIF date"?

heya,

Awesome, thanks to both kazuo and jwwolf.

I ended up using the jhead apporach simply because well, I guess I'm lazy and it seems easier...haha...but I really should patch up on my awk-fu as well, I suppose.

Thanks,
Victor

Offline

Board footer

Powered by FluxBB