For a bunch of jpg photos, I have this (simplified) script to be able to extract the original date when the photo was taken (if different of 0000:00:00, not relevant for this case)
for f in *.jpg;
do
echo -n $f " >> " ;
/usr/bin/exiv2 -P E pr $f | grep 'Exif.Photo.DateTimeOriginal';
done
But the pipe from exiv2 to grep sometimes retrieves the info present in the metadata of photos, sometimes not.
The file list test set is:
$ ls
sany0070.jpg sany0071.jpg sany0072.jpg sany0073.jpg sany0074.jpg
What I get from this, is an inconsistent result, such as:
$ for f in *.jpg; do echo -n $f " >> " ; /usr/bin/exiv2 -P E pr $f | grep 'Exif.Photo.DateTimeOriginal'; done
sany0070.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0071.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0072.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0073.jpg >> Binary file (standard input) matches
sany0074.jpg >> Binary file (standard input) matches
A second time (the script was able to grep as expected):
$ for f in *.jpg; do echo -n $f " >> " ; /usr/bin/exiv2 -P E pr $f | grep 'Exif.Photo.DateTimeOriginal'; done
sany0070.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0071.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0072.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0073.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0074.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
A third time (not able to grep the info asked, although it was different from the first attempt:
$ for f in *.jpg; do echo -n $f " >> " ; /usr/bin/exiv2 -P E pr $f | grep 'Exif.Photo.DateTimeOriginal'; done
sany0070.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0071.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0072.jpg >> Binary file (standard input) matches
sany0073.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
sany0074.jpg >> Exif.Photo.DateTimeOriginal Ascii 20 0000:00:00 00:00:00
And so on.
I'm running Slackware64 14.2 Linux with:
$ grep -V
grep (GNU grep) 2.25
$ exiv2 --version
exiv2 0.25 001900 (64 bit build)
I'd like to know why this is happening and how to deal with this.
Edit: This happens to this set of files (five in the example as a sample of the 76 of the original directory), but has not happened to hundreds of other ones in dozens of directories I applied it with no problems.