Add more img management tools
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
function imgaddexif () (
|
||||
#set -x
|
||||
FLAG_DTO=0
|
||||
FLAG_DRYRUN=1
|
||||
FLAG_OVERWRITE=0
|
||||
|
||||
function _print_help() {
|
||||
echo "Add fixed DateTimeOriginal"
|
||||
echo ""
|
||||
echo "Usage: imgfn2exif <options> <file-selection>"
|
||||
echo " <file-selection> : for example *.JPG"
|
||||
echo " <options> : The following options are available:"
|
||||
echo " : -dto date time format"
|
||||
echo " : -d write exif information"
|
||||
echo " : -o overwrite existing exif information"
|
||||
}
|
||||
|
||||
function _new_exif () {
|
||||
file=$1
|
||||
file_name=$(basename ${file})
|
||||
file_name_prefix=${file_name%.*}
|
||||
|
||||
if [ $FLAG_DRYRUN -eq 1 ]; then
|
||||
cmd=(echo)
|
||||
else
|
||||
cmd=()
|
||||
fi
|
||||
cmd+=(exiftool -overwrite_original -DateTimeOriginal=${FLAG_DTO} ${file})
|
||||
if [ $FLAG_OVERWRITE -eq 0 ]; then
|
||||
current_exif=$(exiftool -DateTimeOriginal ${file})
|
||||
if [ ! -z $current_exif ]; then
|
||||
echo "Exif DateTimeOriginal already exists for ${file}: ${current_exif#*: }"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo Executing: ${cmd}
|
||||
"${cmd[@]}"
|
||||
}
|
||||
|
||||
while true; do
|
||||
case $1 in
|
||||
-d)
|
||||
FLAG_DRYRUN=0
|
||||
shift;
|
||||
;;
|
||||
-dto)
|
||||
shift;
|
||||
FLAG_DTO=$1
|
||||
shift;
|
||||
;;
|
||||
-h)
|
||||
_print_help
|
||||
exit 0
|
||||
;;
|
||||
-o)
|
||||
FLAG_OVERWRITE=1
|
||||
shift;
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $FLAG_DTO -eq 0 ]; then
|
||||
echo "You need to provide a date time format; see help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for f in $@; do
|
||||
_new_exif $f
|
||||
done
|
||||
)
|
||||
Reference in New Issue
Block a user