Wahrscheinlich gibt es sowas bereits, aber wen nicht – hier das Skript. Es ist relativ schnell zusammen geschustert und noch relativ wenig "verallgemeinert".
Mfg,
Michi
Aufruf:
wenn die DNG-Datei im selben Ordner oder im Ordner ../100CANON liegt:
- Code: Alles auswählen
$ ./blkexivcp.sh IMG_1234.JPG IMG_1235.JPG … IMG_9999.JPG
wenn sie sonst wo leigt:
- Code: Alles auswählen
$ ./blkexivcp.sh -p path/to/raw IMG_1234.JPG IMG_1235.JPG … IMG_9999.JPG
Code: (hochladen von .sh-files hier nicht erlaubt)
- Code: Alles auswählen
#!/bin/bash
############################################################################
# blkexivcp.sh - bulk copy exiv data from one file to another
# Copyright (C) 2012 Michael F. Schönitzer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
############################################################################
# for debuging
#set -x
in_prefix=CRW
in_extension=DNG
# -h and -? prints' help message
if [ "$1" = "-h" -o "$1" = "-?" ] ; then
echo "Usage:"
echo "./blkexivcp.sh [-p <path>] <file> [<file2> …]"
echo ""
echo -e "File(s) must be the file(s) where the Exiv-data should be written in.\n"
echo -e "The Exiv-data is search in a file caled ${in_prefix}_<number>.${in_extension},\
with the same numer as in <file>. The file is searched in the same directory and in ../100CANON by default.\n" | fold -s -w 65
echo "Use -p to give an alternativ path to search the DNG-file in."
exit 0
fi
if type exiv2 > /dev/null ; then :; else
echo "Please install exiv2"
exit 1
fi
# Path of infile can be given with -p <path>
if [ "$1" = "-p" ] ; then
inpath="$2/"
shift 2
else
inpath=""
fi
# Run loop: edit every given file
for i in $*; do
infile=${inpath}${in_prefix}_${i:4:4}.${in_extension}
outfile=$i
ifile=${infile/.*/} # outfile without extension
ofile=${outfile/.*/} # infile without extension
# Test if given outfile is there
if [ ! -f $outfile ] ; then
echo "Outputfile ($oufile) not found. Must to be in the directory!"
continue
fi
# Test if infile can be found
if [ -f $infile ] ; then
:
# also search in ../100CANON
elif [ -f ../100CANON/$infile ] ; then
infile=../100CANON/$infile
else
echo "Inputfile ($infile) not found."
continue
fi
# Extract Exiv-data into .exv-file
exiv2 ex $infile
mv ${ifile}.exv ${ofile}.exv
# Theres a problem with the Resolution-value given,
# so we copy them by hand into the new .exv-file
# if something works wrong by that, we delete them,
# because no data is better than wrong data. (They are not realy needed anyway)
width=$(exiv2 -g Exif.Photo.PixelXDimension $outfile | tr -s \ | cut -d\ -f4)
length=$(exiv2 -g Exif.Photo.PixelYDimension $outfile | tr -s \ | cut -d\ -f4)
if [ "$width" != "" ] ; then
exiv2 -M "set Exif.Image.ImageWidth Long $width" ${ofile}.exv
else
exiv2 -M "del Exif.Image.ImageWidth" ${ofile}.exv
fi
if [ "$length" != "" ] ; then
exiv2 -M "set Exif.Image.ImageLength Long $length" ${ofile}.exv
else
exiv2 -M "del Exif.Image.ImageLength" ${ofile}.exv
fi
# Write Exiv-data from exv-file into outputfile
exiv2 in $outfile
rm ${ofile}.exv
done