Add new command to manage images / media

This commit is contained in:
2023-05-01 13:46:02 +02:00
parent bf26d36cae
commit 2dfb3240cb
2 changed files with 60 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
function imgfn2exif () (
#set -x
FLAG_DRYRUN=1
FLAG_OVERWRITE=0
function _print_help() {
echo "Use filename to get DateTime from image and add as DateTimeOriginal Exif information"
echo ""
echo "Usage: imgfn2exif <options> <file-selection>"
echo " <file-selection> : for example *.JPG"
echo " <options> : The following options are available:"
echo " : -d write exif information"
echo " : -o overwrite existing exif information"
}
function _img_fn_2_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=${file_name_prefix} ${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;
;;
-o)
FLAG_OVERWRITE=1
shift;
;;
*)
break
;;
esac
done
for f in $@; do
_img_fn_2_exif $f
done
)
+2
View File
@@ -126,6 +126,8 @@ source $DOTCONFDIR/dotconf.sh
### Shell function definition ### Shell function definition
source $DOTCONFDIR/zsh/funcs/*.sh
function _sortimages () { function _sortimages () {
SOURCE="$1" SOURCE="$1"
TARGET_PREFIX="$2" TARGET_PREFIX="$2"