I got tired of pulling tons of photos off my wife's camera

GrouchyGaijin

See below for version 3 of the script.
The heavy lifting was done by schragge at the Ubuntu Forum's Programming sub-forum.

So - I wrote a VERY simple script to pull everything off.
It puts the images in a folder labeled with the date.
It resizes the images for posting on my website.
(I live in Sweden, but am from the US, my wife is from Japan - so we have a website devoted to our kids.  Both sets of Grandparents love it.)
It puts the videos in a folder I use to store clips until I can edit them.
It removes all the thumbnail (.THM) files from the camera.

Anyway,  here it is:

### Unload_camera ###
### By Grouchy Gaijin ###
### Tweaked by Sector_11 ###
### This is really simple.  You only need to install GraphicsMagick to resize the images and then adjust
###the paths of the folders. ###
### Make the script executable chmod +x Unload_camera and call the script from the camera. ###


#!/bin/bash
echo "Are you SURE you are in the right folder??"
##### Because I am a dumbass and sometimes run this from the wrong folder. #####
echo "ALL files in the clips folder will be deleted."
#### Because I always forget to delete them after I post a video #####
read -p "If so, press the [Enter] key continue..."

# now is the folder where the script will put your photos #
# I have the date set in the format of 15-Apr-2013 #
now=$(date +"%d-%b-%Y")

# gm mogrify is the GraphicsMagick command to resize all jpeg files in the source direcory #

gm mogrify -resize 720x720 *.jpg *.JPG

# change the path of mkdir to where ever you want the new direcory to be #
mkdir ~/path/to/$now &&
mv *.JPG ~/path/to/$now
mv *.jpg ~/path/to/$now

# The script will pull any videos off your camera and put them in the assigned direcory #
# My direcory is called clips.  Before moving new videos into the clips direcory, the script will delete # # anything it finds there. #

rm -f /path/to/the/direcory/where/you/store/all/of/your/clips/before/editing/*

# The script also removes any video thumbnail files from the camera #
# I added .MOV and .mov in case you pull from a drive with Mac files on it (iPhone, cough cough) #
rm *.THM
mv *.MPG /path/to/destination/folder/
mv *.MOV /path/to/destination/folder/
mv *.mov /path/to/destination/folder/
Thank you,

GG

VastOne

VSIDO      VSIDO Change Blog    

    I dev VSIDO

Sector11

Looks good.  Now I if only I could get my camera to work with Linux  :(
Stay Home

GrouchyGaijin

#3
Took care of some repetitive tasks via functions.

#!/bin/bash
echo "Unload_camera version 3.1: This script will remove images and videos from your camera."
echo "Basic script by GrouchyGaijin. Heavy lifting by schragge. Additional modifications by cortman, steeldriver, and ofnuts"
echo "Run this script from the camera" 
now=$(date +"%d-%b-%Y-%T")
mkdir /path/to/where/you want/the/pictures/put/$now
echo "Making directory to hold the photos."

dir="/path/to/clips/directory"
read -p "Press Enter to check if the clips directory is empty"
if [ "$(ls -A $dir)" ]; then
     echo "Clips is not empty. Did you forget to empty it last time?"
fi
echo "If files were found type yes to empty the directory"
read x
if [ "$x" = "yes" ]
then
rm -f "$dir"/*
else
echo "OK, Leaving the directory as is."
fi
                 
pics_dir="/path/to/$now"
clips_dir="/path/to/clips"

process_image() {
  echo Resizing "$1"
  gm mogrify -resize 720x720 "$1"
  echo Moving "$1" to $pics_dir
  mv "$1" "$pics_dir"
}
process_video() {
  echo Moving "$1" to $clips_dir
  mv "$1" "$clips_dir"
}

process_thumbnail() {
  echo Removing "$1" from the camera
  rm "$1"
}

unload() {
  case $1 in
    image) pattern='*.jpg *.JPG *.png *.PNG *.GIF *.gif';;
    video) pattern='*.MOV *.mov *.mpg *.MPG *.mpeg *.mp4';;
    thumbnail) pattern='*.THM';;
    *) echo Unknown file type, aborting...; exit 1;;
  esac
  echo Press Enter to search for $1 files; read start

  unset found
  for i in $pattern; do
    if [[ -f $i ]]; then
      [[ -v found ]] || echo ${1^}s found.
      : ${found:-set}
      process_$1 "$i"
    else
      echo Skipping $i: not a regular file
    fi
  done
  [[ -v found ]] || echo No or no additional ${1}s found.
}
shopt -s nullglob
unload image
unload video
unload thumbnail
Thank you,

GG