#!/bin/bash # # If you want to use this with Ubuntu Hardy, you cannot use the "Removable # Drives and Media" settings as they are now ignored. Instead the Nautilus # Preferences are used, and these are based on mime-type handlers. # # To work around this issue, edit /etc/gnome/defaults.list and add/change the # image-dcf handler to: # # x-content/image-dcf=sync-camera.desktop # # Then create a sync-camera.desktop file in /usr/local/share/applications with # the following contents: # # [Desktop Entry] # Version=1.0 # Encoding=UTF-8 # Name=Randomwalking Photo Import # MimeType=x-content/image-dcf; # Exec=/usr/local/bin/sync-camera.sh %f # NoDisplay=true # StartupNotify=true # Terminal=true # Type=Application # Categories=Graphics;Photography;GNOME;GTK; # # Finally, copy this file into /usr/local/bin/sync-camera.sh. # # Now you should be able to select this photo importer from within the # Nautilus preferences if [ -d $1/DCIM ]; then YEAR=`date +%Y` DST=/home/shared/Photos/$YEAR gmessage -buttons "GTK_STOCK_OK:0,GTK_STOCK_CANCEL:1" \ "Do you want to import pictures from $1 to ${DST}" if [ $? -eq 0 ]; then mkdir -p ${DST} # Import all the subfolders for folder in $( find $1/DCIM -type d ); do if [ $folder != $1/DCIM ]; then echo "Importing $folder" cd $folder rsync -rtv --exclude="*?.THM" --modify-window=1 --progress --ignore-existing . $DST cd - # Remove photos from the card that are over 7 days old echo "Removing old photos" find $folder -type f -mtime +7 -exec rm '{}' ';' df -h | grep "/media/disk" fi done chmod -R o-w ${DST}/* chgrp -R photos ${DST}/* chmod -R g+r,u+r ${DST}/* gmessage -buttons "GTK_STOCK_OK:0" "Done syncing!" fi fi