Last active
December 13, 2015 18:38
-
-
Save kilaulena/4956867 to your computer and use it in GitHub Desktop.
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 | |
# Tells you how your photos are distributed over the year - in which months do you take the most photos? | |
# | |
# call with | |
# ./stats.sh 2>/dev/null | |
# because there will be some broken exif data | |
date | |
echo "Total photos:" | |
find "/Users/Shared/iPhoto Library/Originals/" -iname '*.jpg' | while read f; do | |
timestamp=`exiv2 "$f" | grep timestamp`; | |
read X X X month X X X X <<<${timestamp//:/ } | |
echo $month | |
done | sort | uniq -c | sort -r > "result.txt" | |
total=0 | |
month_numbers=(01 02 03 04 05 06 07 08 09 10 11 12) | |
while read line; do | |
line_without_blanks="$line"; | |
read count month <<<${line_without_blanks//:/ } | |
for m in ${month_numbers[*]}; do | |
if [ "$month" = "$m" ]; then | |
echo "$month: $count" >> "stats.txt" | |
total=$(($total+$count)) | |
fi | |
done | |
done < "result.txt" | |
cat stats.txt | |
echo $total | |
echo ------ | |
while read line; do | |
line_without_blanks="$line"; | |
read month count <<<${line_without_blanks//:/ } | |
percent=$(($count * 10000 / $total)) | |
length=${#percent} | |
offset=$(( $length-2 )) | |
if [ $offset = 0 ]; then | |
echo Month $month: 0.${percent:$offset}% | |
else | |
echo Month $month: ${percent:0:$offset}.${percent:$offset}% | |
fi | |
done < "stats.txt" | |
# rm stats.txt | |
date | |
# | |
# Output: | |
# | |
# Do 14 Feb 2013 23:39:44 CET | |
# Total photos: | |
# 08: 4072 | |
# 09: 2815 | |
# 05: 2330 | |
# 04: 2024 | |
# 07: 1901 | |
# 03: 1853 | |
# 06: 1791 | |
# 12: 1360 | |
# 10: 1295 | |
# 11: 830 | |
# 01: 776 | |
# 02: 693 | |
# 21740 | |
# ------ | |
# Month 08: 18.73% | |
# Month 09: 12.94% | |
# Month 05: 10.71% | |
# Month 04: 9.31% | |
# Month 07: 8.74% | |
# Month 03: 8.52% | |
# Month 06: 8.23% | |
# Month 12: 6.25% | |
# Month 10: 5.95% | |
# Month 11: 3.81% | |
# Month 01: 3.56% | |
# Month 02: 3.18% | |
# Do 14 Feb 2013 23:42:45 CET | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment