Skip to content

Instantly share code, notes, and snippets.

@dmpop
Last active July 10, 2017 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmpop/ec339f5a7e93e43d5e2a to your computer and use it in GitHub Desktop.
Save dmpop/ec339f5a7e93e43d5e2a to your computer and use it in GitHub Desktop.
Bash shell script to extract camera and lense data from the digikam4.db database
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Based on https://github.com/silviuvulcan/digikam-stats/blob/master/digikam_stats.sh
# Dependency SQlite 3. Use the sudo apt-get install sqlite3 to install it on Debian and Ubuntu.
USAGE='
USAGE: \n
help - shows this help\n
cameras - shows camera statistics\n
lenses - shows lens statistics\n
'
if [ "$1" == "help" ]; then
echo -e $USAGE
exit 0
fi
if [ "$1" != "cameras" ]&&[ "$1" != "lenses" ]; then
echo -e $USAGE
exit 0
fi
if [ "$1" == "cameras" ]; then
sqlite3 -header digikam4.db "SELECT make,model,count(*) FROM ImageMetadata GROUP BY make,model ORDER BY count(*) DESC;"
sqlite3 -header -csv digikam4.db "SELECT make,model,count(*) FROM ImageMetadata GROUP BY make,model ORDER BY count(*) DESC;" > digikam-cameras.csv
fi
if [ "$1" == "lenses" ]; then
sqlite3 -header digikam4.db "SELECT make,model,lens,focalLength,count(*) FROM ImageMetadata GROUP BY make,model,lens,focalLength ORDER BY count(*) DESC;"
sqlite3 -header -csv digikam4.db "SELECT make,model,lens,focalLength,count(*) FROM ImageMetadata GROUP BY make,model,lens,focalLength ORDER BY count(*) DESC" > digikam-lenses.csv
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment