1

How can I find all groups of images which have the same exif timestamp in a given directory from the command line in linux?

2

Well, let's say you are using exiftool and a command like

exiftool -sep $'\t' -T -filename -createdate dir

This prints one line per image in directory dir with the filename and its creation timestamp. I don't know if this is the timestamp you had in mind but you can always change that field.

Pipe output of that command to this awk command

awk 'BEGIN { OFS = "\t" }{ datetime = $2 " " $3 } { files[datetime] = files[datetime] " " $1 } END { for (time in files) print time ":" files[time] }'

...like so...

exiftool -sep $'\t' -T -filename -createdate dir | awk 'BEGIN { OFS = "\t" }{ datetime = $2 " " $3 } { files[datetime] = files[datetime] " " $1 } END { for (time in files) print time ":" files[time] }'

And you'll get output of the form

2016:05:05 00:52:03: IMG_0990.JPG IMG_0962.JPG
2016:05:05 00:51:23: IMG_0965.JPG
2016:05:05 00:48:36: IMG_0956.JPG IMG_0966.JPG IMG_0969.JPG

Note: For the sake of simplicity/sanity I am assuming that the image filenames don't have spaces in them or any other funkiness.

Disclaimer: I'm not an awk expert. There may be more elegant ways to do the same thing.

  • Thanks. Are you sure that the first exiftool command is correct? For me it prints only a \t? – student Oct 1 '17 at 5:59
  • @student I updated with a different exiftool command and a tweak to the awk part to accommodate it. I tested this locally with some images and it's working here. One thing, though, is createdate is probably going to be different for every photo unless you copied them. So choose another tag from the exif data if you need to. – B Layer Oct 1 '17 at 6:13

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.