You are not logged in.
heya,
This isn't strictly a Arch Linux related question, but the community on here is fairly knowledgeable, and it's a scripting question .
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
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
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
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