LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2010, 02:27 PM   #1
rioguia
Member
 
Registered: Jun 2002
Posts: 411

Rep: Reputation: 30
search recursively by exif date?


I have searched diligently but can't seem to find a way to search by exif date. Most of my searches turned up commands to manipulate EXIF data not just search by it.


I have found some likely tools but suspect that I don't know enough bash to recursively find a .jpg file by it's exif date.

For example, exiprobe and exifgrep look promising (see examples below).

i have made some progress. At first, I couldn't associate the file name with the date given but learned that the "n" option forces each output line to start with the file name.

Now, I need to make the command recurse but can't seem to manage it. Any help would be appreciated.

halloween_IMG_0965.JPG: JPEG.APP1.Ifd0.Exif.DateTimeOriginal = '2009:10:31 20:58:52


If it helps, I have linked to the man pages

http://www.virtual-cafe.com/~dhh/too...ifprobe.1.html
http://www.virtual-cafe.com/~dhh/too...xifgrep.1.html
 
Old 02-20-2010, 05:03 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
Here is an example using the exif program that comes with libexif to pull out the tags:

Code:
find -name '*.jpg' -exec sh -c '[[ $(exif -t DateTimeOriginal -m "{}") =~ ^2005:01:.. ]]' \; -print
You could apply this same technique to the other EXIF extraction programs too.

The find looks for jpg files. For each file found, it executes a shell which does a test on the exif data. The exif flags are '-t' which selects the DateTimeOriginal tag, and '-m' to show only the tag data. The match is a regular expression (in this case all January 2005 dates). If the exec match succeeds, the find goes on to print the filename.
 
Old 02-20-2010, 09:41 PM   #3
rioguia
Member
 
Registered: Jun 2002
Posts: 411

Original Poster
Rep: Reputation: 30
not quite working for me

Thanks for your quick response.
This looks really close but it appears that my Ubuntu hides the bash some place unexpectedly. I got an error messsage
Quote:
sh: [[: not found
. I searched for possible explanations and most seemed to suggest a permission issue. Assuming this might be a permissions error, I
ran the command under sudo with the same results.
 
Old 02-20-2010, 09:52 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
That error is not telling you that is cannot find bash -- it's saying that "[[" is not found.
I would think (but not certain) that /bin/sh would be linked to /bin/bash on your system, thereby allowing the "[[" test (which is a 'Bashism') to execute without error; but as a test, you might try replacing the "sh" in your `find` command, with "bash" instead, and see if it likes that.
Alternately, you might try replacing the "[[" with "[" but my fear is that you would then need to do some quoting of the items within the [ and ] brackets.

So, in short:

1) try replacing "sh" with "bash".
2) if that fails, replace "[[" with "[" (and of course, replace "]]" with "]" as well) and see what happens there. If you try this, you may then get an error about "too many arguments.." which means you will need to, at the least, put qoutes around the things you are testing.

Sasha
 
Old 02-20-2010, 09:56 PM   #5
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
I was assuming at least version 3 of bash. What does this report?:
Code:
sh --version
 
Old 02-20-2010, 10:29 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by rioguia View Post
... but it appears that my Ubuntu hides the bash some place unexpectedly.
This is truer than you imagine. What does this produce
Code:
ls -al $(which sh)
Try using /bin/bash in the solution from neonsignal.
 
Old 02-21-2010, 05:49 AM   #7
rioguia
Member
 
Registered: Jun 2002
Posts: 411

Original Poster
Rep: Reputation: 30
Thanks that solved it!

The /bin/bash suggestions worked.

The output from the which command was as follows;
$ ls -al $(which sh)
lrwxrwxrwx 1 root root 4 2009-06-15 12:30 /bin/sh -> dash

Thanks again!
 
  


Reply

Tags
data, exif, search



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting photos into folders based on exif date SuperJediWombat! Programming 7 05-16-2009 06:53 PM
Delete files for a particular changed date recursively? qwertyme Linux - Newbie 5 01-23-2009 10:41 AM
bash code to recursively remove EXIF info leosgb Programming 4 10-25-2007 12:31 AM
recursively search basak Linux - Software 1 08-13-2006 10:25 AM
Any programs to rename a image to it's EXIF date ? CRego3D Linux - Software 1 11-08-2004 02:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration