Created
June 12, 2022 10:00
-
-
Save loentar/08913e49844d130d9d0b68c515208dec to your computer and use it in GitHub Desktop.
Calculate total drawing time in Krita. run: krita-drawing-time.sh /path/to/your/kra-files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -n "$1" ] | |
then | |
cd "$1" | |
fi | |
readableTime() { | |
value=$1 | |
res="$(($value % 60))s" | |
value=$((value / 60)) | |
if [ $value -gt 0 ] | |
then | |
res="$(($value % 60))m $res" | |
value=$((value / 60)) | |
if [ $value -gt 0 ] | |
then | |
res="$(($value % 24))h $res" | |
value=$((value / 24)) | |
if [ $value -gt 0 ] | |
then | |
res="${value}d $res" | |
fi | |
fi | |
fi | |
echo "$res" | |
} | |
getTagValue() { | |
sed "/<$1>/"'!d'";s/.*>\(.*\)<.*/\\1/" <<< "$doc" | |
} | |
declare -a timings | |
for filename in $(find * -type f -name '*.kra') | |
do | |
doc=$(unzip -p "$filename" documentinfo.xml) | |
title=$(getTagValue title) | |
creationDate="$(getTagValue creation-date | sed 's/[^0-9]//g')" | |
editingTime="$(getTagValue editing-time)" | |
[ -n "$editingTime" ] || editingTime=0 | |
echo -e "$filename\t$title\t$creationDate\t$editingTime\t($(readableTime $editingTime))" | |
existingTime="${timings[$creationDate]:-0}" | |
if [ -z "$existingTime" -o "$existingTime" -lt "$editingTime" ] | |
then | |
timings[$creationDate]=$editingTime | |
fi | |
done | |
total=0 | |
for key in ${timings[@]} | |
do | |
total=$(($total + $key)) | |
done | |
echo -e "total time spent=$total seconds ($(readableTime $total))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Calculates total time for all drawings in directory. If directory name is omitted current directory will be used.
bash krita-drawing-time.sh ~/Pictures