/usr/bin/exifgrep is in exifprobe 2.0.1-1fakesync1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | #!/bin/sh
# @(#) $Id: exifgrep,v 1.11 2005/07/02 13:10:03 alex Exp $
# Run 'egrep' on the output of exifprobe -L, massaging the output a la
# 'list-photo'. Accepts the -var, -export, -num, and '-' options of
# list_photo; all other options are passed to egrep.
usage()
{
echo "Usage: exifgrep [-var|-export] [-num] [-r] [-t] [-n] [-c] [egrep-options] egrep-pattern [NOT egrep-pattern] imagefilename[s]" 1>&2
exit 1
}
# Create the output format, choosing numerical or "interpreted" values
# from the exifprobe output lines, and stripping unwanted spaces for
# "variable" format (while quoting multi-word values).
format()
{
filename=
vars="var nequals nvalue iequals value remainder"
case "${nameopt}" in
"-n") vars="filename var nequals nvalue iequals value remainder" ;;
esac
while read $vars
do
case "$filename" in
"#") continue ;;
"#"*) continue; ;;
*"#") continue ;;
esac
case ${var} in
"#") continue ;;
"#"*) continue; ;;
*"#") continue ;;
esac
if test 0$dovar -ne 0
then
if test ${donum} -eq 1
then
case ${nvalue} in
[0-9]*) echo -n "${export}${var}=${nvalue}" ;;
*) quote ${var} ${nvalue} ${iequals} ${value} ${remainder};;
esac
else
case "${iequals}" in
"") quote ${var} ${nvalue}${value}${remainder} ;;
=) quote ${var} ${value} ${remainder} ;;
APEX) quote ${var} ${remainder} ;;
*) quote ${var} ${nvalue} ${iequals} ${value} ${remainder} ;;
esac
fi
elif test ${donum} -eq 1
then
case ${nvalue} in
"'"*) echo -n "${var}=${nvalue}"
case "${iequals}" in
"") ;;
*) echo -n " ${iequals} ${value} ${remainder}" ;;
esac
;;
*) case "${var}" in
"#") ;;
*) echo -n "${var}=${nvalue}" ;;
esac
;;
esac
else
echo -n $var $nequals $nvalue $iequals $value $remainder
fi
case "${filename}" in
"") echo ;;
*) echo " # ${filename}" ;;
esac
done
}
# On output, place double-quotes around multi-word values which
# are not already quoted. This is necessary for 'variable' format.
# Do not include "commented" material in quoted phrase.
quote()
{
local inquote
inquote=0
case $# in
0) ;;
1) echo -n "${export}$1=" ;;
2) echo -n "${export}$1=$2" ;;
*) case $1 in
\#*) echo -n "$1" ;;
*) echo -n "${export}$1"= ;;
esac
shift
while test $# -gt 0
do
case $1 in
\'*) echo -n $*; break ;;
\#*) case $inquote in
1) echo -n "' " ;;
esac
inquote=0
echo -n "$*"
break
;;
*) case $inquote in
0) echo -n "'"; inquote=1 ;;
esac
echo -n "$1"
shift
;;
esac
done
case $inquote in
1) echo -n "'" ;;
esac
;;
esac
}
exifgrep_imagefind()
{
local dir
dir="$*"
find ${dir:="."} \
\( \
-iname "*.tiff" -o -iname "*.tiff" -o -iname "*.tiff.Z" \
-o -iname "*.tif" -o -iname "*.tif" -o -iname "*.tif.Z" \
-o -iname "*.jpeg" -o -iname "*.jpeg.gz" -o -iname "*.jpeg.Z" \
-o -iname "*.jpg" -o -iname "*.jpg.gz" -o -iname "*.jpg.Z" \
-o -iname "*.jpe" -o -iname "*.jpe.gz" -o -iname "*.jpe.Z" \
-o -iname "*.kqp" -o -iname "*.kqp.gz" -o -iname "*.kqp.Z" \
-o -iname "*.mrw" -o -iname "*.mrw.gz" -o -iname "*.mrw.Z" \
-o -iname "*.nef" -o -iname "*.nef.gz" -o -iname "*.nef.Z" \
-o -iname "*.orf" -o -iname "*.orf.gz" -o -iname "*.orf.Z" \
-o -iname "*.pef" -o -iname "*.pef.gz" -o -iname "*.pef.Z" \
-o -iname "*.x3f" -o -iname "*.x3f.gz" -o -iname "*.x3f.Z" \
-o -iname "*.dng" -o -iname "*.dng.gz" -o -iname "*.dng.Z" \
-o -iname "*.erf" -o -iname "*.erf.gz" -o -iname "*.erf.Z" \
-o -iname "*.raf" -o -iname "*.raf.gz" -o -iname "*.raf.Z" \
-o -iname "*.cr2" -o -iname "*.cr2.gz" -o -iname "*.cr2.Z" \
-o -iname "*.crw" -o -iname "*.crw.gz" -o -iname "*.crw.Z" \
-o -iname "*.jp2" -o -iname "*.jp2.gz" -o -iname "*.jp2.Z" \
-o -iname "*.k25" -o -iname "*.k25.gz" -o -iname "*.k25.Z" \
-o -iname "*.kdc" -o -iname "*.kdc.gz" -o -iname "*.kdc.Z" \
\) -print
}
: PROBE=${PROBE:=exifprobe}
# Gather options first. This is kind of wierd.
dovar=0
donum=0
recursisve=0
export=
egrep_options=
vgrep_options=
pattern=
notpattern=
nameopt=
tagopt=
coloropt=
while test $# -ge 1
do
case $1 in
-var) dovar=1; shift ;;
-num) donum=1; shift ;;
-c) coloropt="-c" ; shift ;;
-n) nameopt="-n"; shift ;; # may need this if reading from stdin
-r) recursive=1; shift ;;
-t) tagopt="-enN" ; shift ;;
-export*) export="export "; dovar=1; shift ;;
-h) usage ;;
-*) egrep_options="$egrep_options $1"; shift ;;
NOT) case "$2" in
-f) notpattern="-f $3"; shift; shift; shift; break ;;
*) notpattern="$2"; shift; shift; break ;;
esac
;;
*) pattern=$1; shift
case $1 in
NOT) case "$2" in
-f) notpattern="-f $3"; shift; shift; shift; break ;;
*) notpattern="$2"; shift; shift; break ;;
esac
;;
*) break ;;
esac
;;
esac
done
if test $# -lt 1 -a "X${pattern}${notpattern}" = "X"
then
usage
fi
# This should probably be modified somehow to use xargs.
case "${recursive}" in
1) args=$( exifgrep_imagefind $* )
set -- ${args}
;;
esac
# All variables are global.
# If there are no filenames, read from stdin, which is expected to be
# exifprobe -L output.
case $# in
0) egrep ${egrep_options} ${pattern} | format
;;
*) case $# in
1) ;;
*) nameopt="-n" ;; # Use names if more than one file
esac
case "${notpattern}" in
"") ${PROBE} -L ${coloropt} ${nameopt} ${tagopt} $* | egrep ${egrep_options} ${pattern} | format ;;
*) case "${pattern}" in
"") ${PROBE} -L ${coloropt} ${nameopt} ${tagopt} $* | egrep ${egrep_options} -v ${notpattern} | format ;;
*) ${PROBE} -L ${coloropt} ${nameopt} ${tagopt} $* | egrep ${egrep_options} ${pattern} | egrep -v ${notpattern} | format ;;
esac
;;
esac
;;
esac
|