#!/bin/bash
#
# OneTouchPhotoDumpToJournal.sh
#
# Version : 0.1
# Latest version is always available at http://www.ruwenzori.net/code/OneTouchPhotoDumpToJournal/
#
#
# What :
#
# Copies all images from a removable media to
# the directory of the day (created on the fly
# if not existing), autorotates them and sets
# the permissions right.
#
# This is a trivial script but it saves me
# much manipulation each time I come back to my
# workstation with removable media full of photos.
#
#
# Dependancies :
# - jhead
#
# Author : Jean-Marc Liotier
#
# Changelog :
# 0.1   20051114        Initial version
#
#
# License
#
# 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 2 of the License, or (at
# your option) any later version.


####################################
# User configurable variables
####################################
#
# Where the date directories pile up
PhotoDumpRootdir="/home/jim/Photo/Journal"
#
# "jpg" works fine for Canon Cameras.
PhotoFileExtension="jpg"
#
# Who should ownership of the files be finally given to
# if ownership change is possible
MyUser="jim"
#
SourceDevice="/dev/sdc1"
MountPoint="/mnt/sdc1-tank_CF"
#
####################################
# End of user-configurable variables
####################################


mount $SourceDevice $MountPoint

# `date +%Y%m%d` may be replaced by any format
# including a hardcoded value such as "20051109"
Today=`date +%Y%m%d`

ZeDir=$PhotoDumpRootdir/$Today
mkdir $ZeDir
find . | grep .jpg | while read ZeFile
    do
        cp $ZeFile $ZeDir
    done
umount $SourceDevice &
jhead -autorot $ZeDir/*
chown -f -R $MyUser:users $ZeDir &

# World-readability is hardcoded by default.
# You may want to change the permissions to something else.
chmod 755 $ZeDir &
chmod 644 $ZeDir/* &