Recent Changes - Search:



My journals will take the place of a blog. They have moved to

Sites I take responsibility for






Places I frequent



Items for sale:


edit SideBar

How to copy photos from iOS devices such as iPhone and iPad to a Linux server

Include our styles below Infobox - invoke as >>infobox<< ... >><<

Codebox: - invoke as >>codebox<< ... >><<

warnbox: - invoke as >>codebox<< ... >><<

editingbox: - invoke as >>codebox<< ... >><<

noticebox: - invoke as >>codebox<< ... >><<

Page bread crumbs:

Pages by tags: (:listtags:)
Subscribe to this wiki: RSS Feed RSS or subscribe to this page for changes: RSS Feed RSS
496 articles have been published so far. Recent changes
(:addThis btn="custom":)

Most of the solutions I present here are free or have a completely free alternative.

Synopsis: I wanted a solution by which I did not have to use iTunes to sync with iPad (iPad: Generation 3, wi-fi only 64GB, iPhones: Gen 4, 8GB). As part of that goal I wanted pictures taken from these devices (mine, work, my iPad and my wife's iPhone) all to be stored to a particular directory on one of Linux servers that has a web server running on it.

The reason for this is depending on if the pictures are public or private I use either Gallery, Picasa or some custom Perl and PHP code to display my picture albums.

The ingredients you will need to complete this recipe:

  1. A Dropbox account.
  2. Either the iOS Dropbox app (Appstore link) on your iOS device (free) or I use CameraSync ($2.99 US) (Appstore link) simply because it names my pictures in date-stamp naming order which is important for me. I either case you will need the Dropbox app to upload to Dropbox file storage.
  3. rsync software (free) and Dropbox software (free) on your web enabled Linux server or desktop.

Steps to complete this recipe:

  1. Install Dropbox software on your web enabled Linux server or desktop. I won't go into how to do that that in this recipe but have a look at or
  2. Install rsync software on your web enabled Linux server or desktop. I won't go into how to do that that in this recipe but have a look at
  3. Create a directory on your Linux host that will store the pictures. In my vase make sure this location is web or possibly network share enabled such as CIFS (SMB or Samba) or possibly NFS.
  4. Install Dropbox iOS app on your iOS device. Configure it with your login and create a directory in which to store your pictures from this iOS device. If you use Camera Upload you can get some extra free space in your account. See
  5. (Optional) Install CameraSync and configure it to use Dropbox and select the folder in which to sync pictures to. If you do this be sure to turn off Camera Upload in Dropbox or you will get duplicate differently names files.
  6. Ok so now perform a sync from CameraSync or upload your pictures using Camera Upload from the Dropbox app while connected to a wi-fi source. I don't recommend doing this from cellular unless you have very few pictures as it will be slow and it will eat up your available data plan. Hint: There is no such thing as "unlimited" in the 3G or 4G world.
  7. Now on your Linux host with Dropbox running in the background shortly these pictures should appear on your Linux host using the same folder name you choose before syncing.
  8. Because additional storage in Dropbox is expensive (the first 2GB + whatever Camera Uploads gives you is free) and you have this Linux host sitting here with likely terabytes of disk storage all for free why not leverage that for your picture management and archives? Ok we will need a simple script to get our pictures off of Dropbox and into a management archive on the Linux host. This is where rsync comes in.
  9. I use this simple script to rsync my pictures from the Dropbox folder and add them into my picture management system for further processing. The script then will erase the synced photos from the Dropbox folder allowing for more photos to be copied there and avoiding storage upgrade charges.

Here are the scripts I use from cron twice daily.

(:code lang=Bash wrap=80:)

  1. !/bin/csh -f

set DBDIR="`echo $HOME`/Dropbox" set PHOTOS=/shares/sarah/from_ipads_and_iphones

foreach pdir ( "Kevin Inscoe Personal iPhone" "Kevin Inscoe’s HMH iPhone" "Photos" "iPad Uploads" "Sarahs Photo" )

        set src="`echo $DBDIR`/`echo $pdir`"
        echo "Processing Dropbox folder $src ...."
        ls -ld "`echo $src`"
  1. add -b and --suffix=".dup" to avoid removing duplicate file names
        rsync -avb --suffix=".dup" --exclude=".dropbox" "`echo $src`/" "`echo $PHOTOS`"
  1. Now remove the pictures we found on the Dropbox
        echo "Cleaning up Dropbox folder $src ...."
        ls -l "$src" | wc -l
        find "$src" -type f -exec rm {} \;
        ls -l "$src" | wc -l
  1. Now cleanup any duplicates with a new unique name ending in "dup" before the file type
        find $PHOTOS -type f -name '*.dup' -ls -exec $HOME/bin/ {} \;
        echo "   "
        echo "   "

end (:codeend:)

(:code lang=Bash wrap=80:)

  1. !/bin/csh -f

if ($#argv < 1 ) then

        echo "Usage: $0 filename.dup"
        echo "Renames a duplicate file after using rsync -b --suffix=".dup". Intended to be run from for more info."
        exit 1


set myfile="$1"

  1. Check if myfile exists

if (! -f "$myfile") then

        echo "$myfile does not exist"
        exit 1


set tempa="/tmp/migrate_photos_from_dropbox_to_shares_renamea.tmp" set tempb="/tmp/migrate_photos_from_dropbox_to_shares_renameb.tmp"

if ( -e $tempa ) rm -f $tempa if ( -e $tempb ) rm -f $tempb

  1. We must be good then proceed...
  2. What are we going to call this file then?

set newfiledir="`dirname $myfile`" echo "newfiledir=$newfiledir"

set newfiletmpa="`basename $myfile`" echo "newfiletmpa=$newfiletmpa" set newfiletmp="`echo $newfiletmpa | sed -e 's/\.dup//g'`" echo "newfiletmp=$newfiletmp"

  1. Now I need just the filename and the file type (to the right of the ".") from variable newfiletmp
  2. Grab the file type from the filename

echo $newfiletmp > $tempa gawk -F. '{if (NF>1) {print $NF}}' $tempa > $tempb set newfiletyp="`head -n 1 $tempb`" echo "newfiletyp=$newfiletyp"

  1. Now I need just the file name by itself

echo $newfiletmp > $tempa

  1. I am making a big assumption here that all files will only have one dot "." in the name
  2. but that would be true in image files taken from a camera (.png or .jpg) otherwise I
  3. have a lot morecode here to grab only the last dot from the file name. Ahh thank you MS-DOS

gawk -F. '{print $1}' $tempa > $tempb set newfilename="`head -n 1 $tempb`" echo "newfilename=$newfilename"

set newfile="`echo $newfiledir`/`echo $newfilename`_dup.`echo $newfiletyp`"

echo "Renaming file $myfile to $newfile..."

  1. mv -v "$$myfile" "$newfile"

if ( -e $tempa ) rm -f $tempa if ( -e $tempb ) rm -f $tempb (:codeend:)

Here is some sample Perl code I wrote to rename JPEG's (with Exif data embedded) to date stamp format from legacy cameras that name files in the format IMG_0057.JPG.

(:code lang=Bash wrap=80:)

  1. !/usr/bin/perl

use strict; use warnings; use utf8;

use Image::Magick; use List::Util 'first';

my $dir = $ENV{'PWD'};

  1. my $view = $ENV{'VIEW'};

my $image; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks); my $dsize; my $a; my @exif; my $match; my ($exdate, $extime); my $newfile;

chomp(my @files = `ls $dir`);

print "$0: Starting at " . `date` ."\n";

foreach my $file (@files) {

  if ($file =~ /\.(jpg|jpeg|JPG|JPEG)/) {
  1. ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file);
  2. print "file=$file\n";
  3. Get Exif data
        $image = Image::Magick->new();
        $a = $image->Get('format', '%[EXIF:*]'); # two arguments
        @exif = split(/[\r\n]/, $a);
  1. print join("\n", @exif);
  2. Locate the DateTime EXIF field
        $match = first { /exif:DateTime=/ } @exif;
  1. if ( $match ne "" ) { if ( length $match ) {
                $match =~ s/exif:DateTime=//;
  1. print "\n\nExif DateTime: $match\n";
  2. Now rename the file to the format 2012-12-23 at 07.29.02.jpg
  3. $match now yields 2012:12:23 19:17:33
                ($exdate, $extime) = split(/ /,$match);
                $exdate =~ s/:/-/g;
                $extime =~ s/:/./g;
  1. print "exdate=$exdate, extime=$extime\n"; $newfile = $exdate . " at " . $extime . ".jpg"; if ( $file ne $newfile ) {
                        rename $file, $newfile || die ( "Error in renaming $file!!\n" );
                        print "\nFile $file has been renamed to $newfile\n";
  1. `ls "$newfile"`;
        } else {
  1. print "No Exif data!\n";
  1. print "\n--------------------\n";


print "$0: Ended at " . `date` ."\n"; (:codeend:)


The reason I use CameraSync to synchronize my photos to Dropbox rather than the Dropbox app itself is because I have greater flexibility in the CameraSync application. For instance Dropbox only seems to allow (as of this writing) uploads to the folder "Camera Uploads" and since I share multiple devices with the same Dropbox account I wanted to keep them separate for file collision purposes. Also CameraSync seems to do a better job of file naming based on time stamp and syncing only what's new to the Photo Roll. But as I say above you can certainly perform this task using just the free Dropbox app.

Kevin's Public Wiki maintained and created by Kevin P. Inscoe is licensed under a
Creative Commons Attribution 3.0 United States License.

Back to my web site -

Edit - History - Print - Recent Changes - Search
Page last modified on July 20, 2013, at 12:58 PM EST