Merged detached head into master
This commit is contained in:
parent
99ded7a254
commit
395e0d845e
2 changed files with 72 additions and 1 deletions
71
bin/exif-fixdatetime
Executable file
71
bin/exif-fixdatetime
Executable file
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
export FILELOGLEVEL=ERROR
|
||||||
|
|
||||||
|
datetime_v1 () {
|
||||||
|
branch="$(basename $1)"
|
||||||
|
if [[ $branch =~ ^([0-9]{4})(\.|-)([0-9]{2})(\.|-)([0-9]{2})( |_)([0-9]{2})(\.|-)([0-9]{2})(\.|-)([0-9]{2}).*$ ]]; then
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
datetime_v2 () {
|
||||||
|
branch="$(basename $1)"
|
||||||
|
if [[ $branch =~ ^([0-9]{4})([0-9]{2})([0-9]{2})(_)([0-9]{2})([0-9]{2})([0-9]{2}).*$ ]]; then
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
datetime_v3 () {
|
||||||
|
branch="$(basename $1)"
|
||||||
|
if [[ $branch =~ ^(IMG-)([0-9]{4})([0-9]{2})([0-9]{2})(-WA)([0-9]{2})([0-9]{2}).*$ ]]; then
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedatetime() {
|
||||||
|
filename="$(basename "${@}")"
|
||||||
|
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}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Whatsapp-Bilder
|
||||||
|
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
|
||||||
|
|
||||||
|
echo "$result"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fix_datetime () {
|
||||||
|
file="${@}"
|
||||||
|
loginfo "file: $file "
|
||||||
|
newDateTimeOriginal="$(parsedatetime "$file")"
|
||||||
|
loginfo "newDateTimeOriginal: $newDateTimeOriginal"
|
||||||
|
# logdebug "INFO: DateTimeOrigin and DateCreated set in file
|
||||||
|
#$(exiftool -DateTimeOriginal -CreateDate "$file")"
|
||||||
|
if [ -n "$newDateTimeOriginal" ]; then
|
||||||
|
exiftool "-DateTimeOriginal=$newDateTimeOriginal" -if '(not $datetimeoriginal)' "$file"
|
||||||
|
exiftool '-createdate<datetimeoriginal' -if '(not $createdate and $datetimeoriginal)' "$file"
|
||||||
|
exiftool -createdate -datetimeoriginal "$file"
|
||||||
|
loginfo "----------------"
|
||||||
|
loginfo ""
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
loginfo "Progress only one file from cmdline ${@}"
|
||||||
|
fix_datetime ${@}
|
||||||
|
|
||||||
|
else
|
||||||
|
loginfo "Progress all *.jpg files in pwd $(pwd)"
|
||||||
|
ls *.jpg|while read i; do
|
||||||
|
fix_datetime "$i"
|
||||||
|
done
|
||||||
|
fi
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3dafdfc0424716bae21f5340314f7d90a9ddf4f2
|
Subproject commit cd6f16978d5af4b9fb861be9d728732d72789df3
|
Loading…
Reference in a new issue