| View previous topic :: View next topic |
| Author |
Message |
thusgaard
Joined: Wed Jun 07, 2006 11:21 am Posts: 97 Location: Skanderborg, Denmark
|
Posted: Wed Mar 06, 2013 4:42 am Post subject: If and Grep |
|
|
Hi
I'm trying to create a list of pictures that contain GPS information.
I have all the picture that I need to examin in one directory and I have a bit of script that works, but not as good as I would like.
| Code: | #!/bin/bash
# My first script
for file in 'ls -1';
do if exiftool *.jpg | grep 'GPS L';
then
exiftool *.jpg | grep 'File Name\|GPS L' > test.txt
else
echo "Negativ"
fi
done |
This code scans all the *.jpg files in a dir for GPS information stored in EXIF. Then it saves the filename and the GPS information to a file called test.
My problem how ever is that it saves all the filenames, also the ones not containing EXIF GPS information.
| Code: |
File Name : noEXIFtest.jpg
File Name : noEXIFtest2.jpg
File Name : EXIFtest2.jpg
GPS Latitude Ref : North
GPS Longitude Ref : East
GPS Latitude : 34 deg 56' 17.78" N
GPS Longitude : 135 deg 38' 41.91" E
File Name : EXIFtest.jpg
GPS Latitude Ref : North
GPS Longitude Ref : East
GPS Latitude : 34 deg 56' 17.78" N
GPS Longitude : 135 deg 38' 41.91" E
File Name : noEXIFtest.jpg |
What Am I doing wrong?
J;-)
|
|
| Back to top |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 8000 Location: Warrington, UK
|
Posted: Wed Mar 06, 2013 9:48 am Post subject: |
|
|
Can you post the full output from exiftool on one of the file that does not contain GPS info but does appear in the list. _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
MartyBartfast LXF regular

Joined: Mon Aug 22, 2005 8:25 am Posts: 780 Location: Hants, UK
|
Posted: Wed Mar 06, 2013 9:50 am Post subject: |
|
|
These line are exiftool'ing ALL jpgs so it will always find at least one match:
| Code: |
do if exiftool *.jpg | grep 'GPS L';
then
exiftool *.jpg | grep 'File Name\|GPS L' > test.txt |
you probably want to do
| Code: |
do if exiftool $file | grep 'GPS L';
then
exiftool $file | grep 'File Name\|GPS L' > test.txt
|
you could probably achieve the same result with
| Code: |
exiftool *.jpg | egrep "File Name|GPS L" | egrep -B1 "GPS L" > test.txt |
_________________ I have been touched by his noodly appendage. |
|
| Back to top |
|
 |
thusgaard
Joined: Wed Jun 07, 2006 11:21 am Posts: 97 Location: Skanderborg, Denmark
|
Posted: Wed Mar 06, 2013 12:52 pm Post subject: |
|
|
This last bit works like a charm.
| MartyBartfast wrote: |
you could probably achieve the same result with
| Code: |
exiftool *.jpg | egrep "File Name|GPS L" | egrep -B1 "GPS L" > test.txt |
|
And just for the interested I'll post a full EXIF log of a picture with no GPS info:
| Code: | ExifTool Version Number : 8.60
File Name : noEXIFtest.jpg
Directory : .
File Size : 176 kB
File Modification Date/Time : 2013:01:26 21:55:42+01:00
File Permissions : rw-rw-r--
File Type : JPEG
MIME Type : image/jpeg
JFIF Version : 1.01
Exif Byte Order : Big-endian (Motorola, MM)
Make : Canon
Camera Model Name : Canon IXUS 1100 HS
X Resolution : 240
Y Resolution : 240
Resolution Unit : inches
Software : Paint.NET v3.5.10
Modify Date : 2012:03:02 08:32:06
Exposure Time : 1/500
F Number : 4.5
ISO : 200
Exif Version : 0230
Date/Time Original : 2012:02:27 13:25:08
Create Date : 2012:02:27 13:25:08
Shutter Speed Value : 1/500
Aperture Value : 4.5
Exposure Compensation : 0
Max Aperture Value : 4.5
Subject Distance : 64.4 m
Metering Mode : Multi-segment
Flash : Off, Did not fire
Focal Length : 12.7 mm
Exif Image Width : 3000
Exif Image Height : 4000
Focal Plane X Resolution : 16393.44262
Focal Plane Y Resolution : 16393.44262
Focal Plane Resolution Unit : inches
Sensing Method : One-chip color area
File Source : Digital Camera
Custom Rendered : Normal
Exposure Mode : Auto
White Balance : Auto
Digital Zoom Ratio : 1
Scene Capture Type : Standard
Sensitivity Type : Standard Output Sensitivity and Recommended Exposure Index
Lens Info : 5-60mm f/?
Lens Model : 5.0-60.0 mm
Profile CMM Type : Lino
Profile Version : 2.1.0
Profile Class : Display Device Profile
Color Space Data : RGB
Profile Connection Space : XYZ
Profile Date Time : 1998:02:09 06:49:00
Profile File Signature : acsp
Primary Platform : Microsoft Corporation
CMM Flags : Not Embedded, Independent
Device Manufacturer : IEC
Device Model : sRGB
Device Attributes : Reflective, Glossy, Positive, Color
Rendering Intent : Media-Relative Colorimetric
Connection Space Illuminant : 0.9642 1 0.82491
Profile Creator : HP
Profile ID : 0
Profile Copyright : Copyright (c) 1998 Hewlett-Packard Company
Profile Description : sRGB IEC61966-2.1
Media White Point : 0.95045 1 1.08905
Media Black Point : 0 0 0
Red Matrix Column : 0.43607 0.22249 0.01392
Green Matrix Column : 0.38515 0.71687 0.09708
Blue Matrix Column : 0.14307 0.06061 0.7141
Device Mfg Desc : IEC http://www.iec.ch
Device Model Desc : IEC 61966-2.1 Default RGB colour space - sRGB
Viewing Cond Desc : Reference Viewing Condition in IEC61966-2.1
Viewing Cond Illuminant : 19.6445 20.3718 16.8089
Viewing Cond Surround : 3.92889 4.07439 3.36179
Viewing Cond Illuminant Type : D50
Luminance : 76.03647 80 87.12462
Measurement Observer : CIE 1931
Measurement Backing : 0 0 0
Measurement Geometry : Unknown (0)
Measurement Flare : 0.999%
Measurement Illuminant : D65
Technology : Cathode Ray Tube Display
Red Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract)
Green Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract)
Blue Tone Reproduction Curve : (Binary data 2060 bytes, use -b option to extract)
Image Width : 600
Image Height : 800
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Aperture : 4.5
Image Size : 600x800
Scale Factor To 35 mm Equivalent: 5.6
Shutter Speed : 1/500
Circle Of Confusion : 0.005 mm
Depth Of Field : inf (6.07 m - inf)
Field Of View : 28.4 deg
Focal Length : 12.7 mm (35 mm equivalent: 71.1 mm)
Hyperfocal Distance : 6.70 m
Light Value : 12.3 |
|
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|