add new formats
This commit is contained in:
parent
f8f0931c17
commit
36e295f335
1 changed files with 52 additions and 15 deletions
|
@ -1,28 +1,44 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
[ -z "${move+x}" ] && move=false
|
[ -z "${move+x}" ] && move=false
|
||||||
|
[ -z "${overwrite+x}" ] && overwrite=false
|
||||||
|
|
||||||
export FILELOGLEVEL=WARN
|
export FILELOGLEVEL=WARN
|
||||||
export SCRIPT_LOG=~/logs/exif.log
|
export SCRIPT_LOG=~/logs/exif.log
|
||||||
|
|
||||||
parsedatetime() {
|
parsedatetime() {
|
||||||
filename="$(basename "${@}")"
|
filename="$(basename "${@}")"
|
||||||
if [[ $filename =~ ^([0-9]{4})(\.|-)([0-9]{2})(\.|-)([0-9]{2})( |_)([0-9]{2})(\.|-)([0-9]{2})(\.|-)([0-9]{2}).*$ ]]; then
|
# 2015-09-11_17:41:53-1.jpg
|
||||||
|
if [[ $filename =~ ^([0-9]{4})(\.|-)([0-9]{2})(\.|-)([0-9]{2})( |_)([0-9]{2})(\.|-|:)([0-9]{2})(\.|-|:)([0-9]{2})(\.|-).*$ ]]; then
|
||||||
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[7]#0}" "${BASH_REMATCH[9]#0}" "${BASH_REMATCH[11]#0}")"
|
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[7]#0}" "${BASH_REMATCH[9]#0}" "${BASH_REMATCH[11]#0}")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $filename =~ ^([0-9]{4})([0-9]{2})([0-9]{2})(_)([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then
|
if [ -z "${result}" ]; then
|
||||||
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}")"
|
if [[ $filename =~ ^([0-9]{4})([0-9]{2})([0-9]{2})(_)([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then
|
||||||
|
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}")"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Whatsapp-Bilder
|
if [ -z "${result}" ]; then
|
||||||
if [[ $filename =~ ^(IMG-)([0-9]{4})([0-9]{2})([0-9]{2})(-WA)([0-9]{2})([0-9]{2}).*$ ]]; then
|
# Whatsapp-Bilder
|
||||||
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[4]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}" "00")"
|
if [[ $filename =~ ^(IMG-)([0-9]{4})([0-9]{2})([0-9]{2})(-WA)([0-9]{2})([0-9]{2}).*$ ]]; then
|
||||||
|
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[4]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}" "00")"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# eYe20130323123316.jpg
|
if [ -z "${result}" ]; then
|
||||||
if [[ $filename =~ ^(eYe)([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then
|
# eYe20130323123316.jpg
|
||||||
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[4]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}")"
|
if [[ $filename =~ ^(eYe)([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then
|
||||||
|
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[2]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[4]#0}" "${BASH_REMATCH[5]#0}" "${BASH_REMATCH[6]#0}" "${BASH_REMATCH[7]#0}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${result}" ]; then
|
||||||
|
# ./2016-01-22/IMG_4225.jpg
|
||||||
|
if [[ "$(dirname ${@})" =~ ^.*/([0-9]{4})(\.|-)([0-9]{2})(\.|-)([0-9]{2})$ ]]; then
|
||||||
|
result="$(printf "%04d:%02d:%02d %02d:%02d:%02d" "${BASH_REMATCH[1]#0}" "${BASH_REMATCH[3]#0}" "${BASH_REMATCH[5]#0}" "00" "00" "00")"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$result"
|
echo "$result"
|
||||||
|
@ -40,10 +56,29 @@ fix_datetime () {
|
||||||
case $mime in
|
case $mime in
|
||||||
image/png)
|
image/png)
|
||||||
exiftool "-creationtime=$newDateTimeOriginal" -if '(not $creationtime)' "$file"
|
exiftool "-creationtime=$newDateTimeOriginal" -if '(not $creationtime)' "$file"
|
||||||
;;
|
|
||||||
image/jpeg)
|
|
||||||
exiftool "-DateTimeOriginal=$newDateTimeOriginal" -if '(not $datetimeoriginal)' "$file"
|
exiftool "-DateTimeOriginal=$newDateTimeOriginal" -if '(not $datetimeoriginal)' "$file"
|
||||||
exiftool '-createdate<datetimeoriginal' -if '(not $createdate and $datetimeoriginal)' "$file"
|
exiftool '-createdate<datetimeoriginal' -if '(not $createdate and $datetimeoriginal)' "$file"
|
||||||
|
DEST="Bilder/Tina_und_Jakob"
|
||||||
|
;;
|
||||||
|
image/jpeg)
|
||||||
|
if $overwrite; then
|
||||||
|
exiftool "-DateTimeOriginal=$newDateTimeOriginal" "$file"
|
||||||
|
exiftool '-createdate<datetimeoriginal' -if '($datetimeoriginal)' "$file"
|
||||||
|
else
|
||||||
|
exiftool "-DateTimeOriginal=$newDateTimeOriginal" -if '(not $datetimeoriginal)' "$file"
|
||||||
|
exiftool '-createdate<datetimeoriginal' -if '(not $createdate and $datetimeoriginal)' "$file"
|
||||||
|
fi
|
||||||
|
DEST="Bilder/Tina_und_Jakob"
|
||||||
|
;;
|
||||||
|
video/mp4|video/m4a)
|
||||||
|
if $overwrite; then
|
||||||
|
exiftool "-DateTimeOriginal=$newDateTimeOriginal" "$file"
|
||||||
|
exiftool '-createdate<datetimeoriginal' -if '($datetimeoriginal)' "$file"
|
||||||
|
else
|
||||||
|
exiftool "-DateTimeOriginal=$newDateTimeOriginal" -if '(not $datetimeoriginal)' "$file"
|
||||||
|
exiftool '-createdate<datetimeoriginal' -if '(not $createdate and $datetimeoriginal)' "$file"
|
||||||
|
fi
|
||||||
|
DEST="Videos/Tina_und_Jakob"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
logwarn "unsupportet mimetype $mime for $file"
|
logwarn "unsupportet mimetype $mime for $file"
|
||||||
|
@ -51,15 +86,17 @@ fix_datetime () {
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "${move+x}" ] && echo move || echo nomove
|
|
||||||
loginfo "$(exiftool -filename -createdate -datetimeoriginal "$file")"
|
loginfo "$(exiftool -filename -createdate -datetimeoriginal "$file")"
|
||||||
|
|
||||||
|
|
||||||
case $move in
|
case $move in
|
||||||
true)
|
true)
|
||||||
loginfo "$(exiftool '-Directory<DateTimeOriginal' -d /srv/nfs/data/userdata/SHARED/Bilder/Tina_und_Jakob/%Y/%Y_%m -filename -createdate -datetimeoriginal -if '($datetimeoriginal)' "$file")"
|
echo move
|
||||||
|
loginfo "$(exiftool '-Directory<DateTimeOriginal' -d /srv/nfs/data/userdata/SHARED/${DEST}/%Y/%Y_%m -if '($datetimeoriginal)' "$file" 2>&1 |tee -a dest_exists)"
|
||||||
;;
|
;;
|
||||||
copy)
|
copy)
|
||||||
loginfo "$(exiftool -o . '-Directory<DateTimeOriginal' -d /srv/nfs/data/userdata/SHARED/Bilder/Tina_und_Jakob/%Y/%Y_%m -filename -createdate -datetimeoriginal -if '($datetimeoriginal)' "$file")"
|
echo copy
|
||||||
|
loginfo "$(exiftool -o . '-Directory<DateTimeOriginal' -d /srv/nfs/data/userdata/SHARED/${DEST}/%Y/%Y_%m -filename -createdate -datetimeoriginal -if '($datetimeoriginal)' "$file")"
|
||||||
logwarn "$(readlink -f "$file"): $(exiftool -filename -if '(not ($datetimeoriginal or $createdate))' "$file")"
|
logwarn "$(readlink -f "$file"): $(exiftool -filename -if '(not ($datetimeoriginal or $createdate))' "$file")"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
Loading…
Reference in a new issue