How to use the Canon XTi digital camera in Linux/Script

THis is a script I created. It copies files into a directory with the date, and renames the files with the date, and original. It also accepts command line args that are added to file names.

use Cwd;
 * 1) !/usr/bin/perl


 * 1) Configs
 * 1) Configs

$pic_root="/pub/images/new"; $tmp_dir="/tmp";


 * 1) Date and Time
 * 1) Date and Time

($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime; $year = 1900 + $yearOffset; $month++;

if ( $month < 10 ) { $month = '0'. $month; } if ( $dayOfMonth < 10 ) { $dayOfMonth = '0'. $dayOfMonth; } if ( $hour < 10 ) { $hour = '0'. $hour; } if ( $minute < 10 ) { $minute = '0'. $minute; }

$arg_string=join('_',@ARGV); $date_now = "$year\y-$month\m-$dayOfMonth\d--$hour\h-$minute\m"; $date_now_tmp = "gphoto-photos--$year\y-$month\m-$dayOfMonth\d--$hour\h-$minute\m-$second\s";
 * 1) creating dir/file names
 * 1) print "$year\y-$month\m-$dayOfMonth\d--$hour\h-$minute\m\n";

if ($#ARGV >= 0) { $file_name_prefix = "$arg_string-$year\y$month\m$dayOfMonth\d-"; $last_dir_name = "$year\y-$month\m-$dayOfMonth\d--$hour\h-$minute\m--$arg_string"; } else { $file_name_prefix = "$year\y$month\m$dayOfMonth\d-"; $last_dir_name = "$year\y-$month\m-$dayOfMonth\d--$hour\h-$minute\m"; }


 * 1) Make dir
 * 1) Make dir


 * 1) some error testing

if ( ! -d $tmp_dir ) { print "*ERROR: temp directory -> $tmp_dir DNE!!!!\n";exit; } if ( ! -d $pic_root ) { print "*ERROR: root picture dir -> $pic_root DNE!!!!\n";exit; }
 * 1) if ( system('which gphoto2' ) print "*ERROR: gphoto2 is not installed!!!\n";exit; }

chdir($tmp_dir) || die "*error: bad coding: /some/path ($!)"; mkdir("$date_now_tmp", 0755); chdir($date_now_tmp) || die "*error: bad coding: /some/path ($!)"; system("gphoto2 --get-all-files");
 * 1) Entering and coping to tmp dir

@file_contents = <*>; foreach $file (@file_contents) { $new_file_name = $file_name_prefix. $file; rename($file,$new_file_name); }


 * 1) print "@file_contents\n\n";
 * 2) print "$#file_contents\n\n";

if ($#file_contents == -1) { print "No files dloaded, \n"; } else { chdir($pic_root); foreach $dir_name ($year,$last_dir_name){ #no more month dir if (-d $dir_name) { chdir($dir_name) || die "*error: entering /some/path ($!)"; # print "dir $dir_name entered\n"; } else { mkdir("$dir_name", 0755) || die "*error: cannot mkdir newdir: $!"; chdir($dir_name) || die "*error: entering /some/path ($!)"; # print "dir $dir_name created\n"; }	}

$tmp_pic_files=$tmp_dir. '/' . $date_now_tmp. '/*';	system("mv $tmp_pic_files ."); $cwd=getcwd; print "Photos are now in $cwd\n"; }
 * 1) $currDir = `pwd`;
 * 2) print $currDir;


 * 1) Copying files
 * 1) Copying files


 * 1) system("gphoto2 --get-all-files") || die "*error: maybe no-pics ($!)";

print "Exiting :-)\n";