Grep exif data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep exif data
# 1  
Old 06-25-2012
Grep exif data

I would like to search for regex in the exif data of a large collection of files (mostly jpg, some nef). For instance "grep_exif Tokyo *.jpg" should return the file names of all files which have "Tokyo" in their exif data.

Exiftool could be used to extract the data. I don't really need to grep all of the exif data, but only things like city, location, country, keywords, etc, So if there is a quicker or more convenient tool than exiftool that could be used instead.

Two nice-to-have-not necessary requirements:
1. be insensitive to capitalization (Tokyo/tokyo/tOkYo/...)
2. add options to search only in the City field or only the Keyword field
# 2  
Old 06-25-2012
Code:
 
for i in *.jpg
do
        echo "------------------$i----------------"
        exiftool "$i" | awk '/city/ || /location/ ||/country/ ||/keywords/'
done

# 3  
Old 06-25-2012
Thanks for the reply, but it is not exactly what I am looking for. This script


I want a grep like functionality, so the script should show me the file names in which a certain string (to be supplied on the command line) exists in the exif data.
# 4  
Old 06-25-2012
Surely you can modify it into what you're looking for, though, now that you've seen the principles?

Also -- what's your system?
# 5  
Old 06-25-2012
Not sure what you mean by principles. The script posted just lists the content of city/location/country/keywords and doesn't have any functionality like grep at all.

System is linux/debian. I don't really care what scripting language.
# 6  
Old 06-25-2012
Gash Shell script built on @itkamaraj post. Count the number of times the case-insignificant string occurs in each file. Untested.
Code:
search="$1"
for i in *.jpg
do
        echo "------------------$i----------------"
        count=$(exiftool "$i" | awk '/city/ || /location/ ||/country/ ||/keywords/' | grep -ic "${search}")
        if [ $count -gt 0 ]
        then
               echo "String found in file: $i"
        fi
done

# 7  
Old 06-26-2012
Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get some data from a list, using grep or sed

Hi, my dear friends, I have to use very frequently the command of qsum to check the free node for job submitting. However, qsum always shows all the nodes regardless of their status. occupied p1 100000mb 48:00:00 1 p72 51200mb -- 1 p73 51200mb -- ... (4 Replies)
Discussion started by: liuzhencc
4 Replies

2. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

3. UNIX for Dummies Questions & Answers

Advanced grep'in... grep for data next to static element.

I have a directory I need to grep which consists of numbered sub directories. The sub directory names change daily. A file resides in this main directory that shows which sub directories are FULL backups or INCREMENTAL backups. My goal is to grep the directory for the word "full" and then... (2 Replies)
Discussion started by: SysAdm2
2 Replies

4. Shell Programming and Scripting

How can i grep for an hour before data

Hi, My log file is something like this. (08/04/2009 00:27:42.179)(:) aaaaaaaaaaaa (08/04/2009 00:27:42.181)(:) bbbbbbbbbbbbbbbb (08/04/2009 01:00:42.713)(:) cd cdc d ddddsksjdkssksksj (08/04/2009 01:02:42.716)(:) raarrarararararara (08/04/2009 01:07:43.036)(:ERROR) Port... (8 Replies)
Discussion started by: rdhanek
8 Replies

5. Shell Programming and Scripting

Ho can i grep for yestdarday's data in unix

I have the date field in my log file in the format shown below.. (07/23/2009 03:54:02.107)aaaaaa bbbbbb I want to grep for month/date(7/23) field of yestdarday's data. found the below command in this forum which is not working in my SUN Solaris box. date -d "yesterday" +"%d %b %Y" ... (3 Replies)
Discussion started by: rdhanek
3 Replies

6. Shell Programming and Scripting

i want to grep some data from other file

helo all i have 2 files. and i want to grep the contents of first file from the 2nd file. but these files are too large contaning lacks of lines . i'm using for loop but it takes so moch times . is there any other sol. i'm using this code " for var in `cat succ_migrated` do grep $var... (4 Replies)
Discussion started by: dodasajan
4 Replies

7. Shell Programming and Scripting

grep required data from two columns

hello, I have output from a command and I need to filter some info out of that. I tried awk command but I can not grep what I am looking for: Following is the output and I need to capture "disabled" for each volume from first column and report: # vol status Volume State ... (2 Replies)
Discussion started by: za_7565
2 Replies

8. Shell Programming and Scripting

grep data and add to file

Hey, i need to write a bash program that can run through a liste of files and then pick up the last access time and modification times and then write them to a file. If anyone has done something like this before, please help me. Thanks (5 Replies)
Discussion started by: nbananda
5 Replies

9. Shell Programming and Scripting

Pipe Data From Grep Into A File

I am somewhat of a novice at unix scripting and I need a little help. Here is what im trying to do: I am trying to figure out how to pipe the following grep results into a file. /source/programs: grep "WSBL020" W* WBMB991.cbl: COPY WSBL020. WDCB003.cbl: COPY... (4 Replies)
Discussion started by: katinicsdad
4 Replies

10. Shell Programming and Scripting

grep data from files

Hello Pls help me i need script for counting number of fails from file . The file contains number of failuer records . (2 Replies)
Discussion started by: getdpg
2 Replies
Login or Register to Ask a Question