LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-31-2005, 02:14 PM   #1
taboom
LQ Newbie
 
Registered: Aug 2005
Distribution: debian sarge (3.1)
Posts: 9

Rep: Reputation: 0
Automatically copy images off digital camera


I haven't found any programs doing this (in Linux):
- when a camera is connected (and recognized) it
- creates a folder according to the images/computers date (and checks that one doesn't exist, else it makes a [date-x] folder, where x is a rising number)
- copies all images to this folder
- asks permission to delete the images (or not, should be possible to specify)
- informs about the actions taken/openes the downloaded images folder should also be possible to specify).

I can't see this could be anything hard to create, but will I need to make this script myself, or is it just that I can't find this kind of a program? It could certainly exist, as this is something ppl probably want.

Thank's in advance
 
Old 08-31-2005, 02:41 PM   #2
shane25119
Member
 
Registered: Aug 2003
Location: Illinois
Distribution: Linux Mint XFCE
Posts: 654

Rep: Reputation: 53
Well, I know that each time I plug my memory card into my card reader on my Ubuntu Desktop it offers to copy all the images off of the memory card for me. I'm not sure on the name of the program that pops up with that one... I'm on a laptop at school now and it's quite difficult to get Linux working here so I am using Windows... ugh... if no one else posts the name of that program I will check it when I get home tonight and post it for you.

S
 
Old 08-31-2005, 03:08 PM   #3
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Gphotolib, once you've set it up initially, will do all of that in about 3 commands. If you've not gotten gphoto set up yet I got a little verbose when doing mine and posted it all here.

That said, here's a little script which doens't have a whole lot of error checking (you can do that yourself if it gets to be a hassle), but which will do what you want:

Code:
#!/bin/bash

# Camera all plugged in and ready?  Good!

today=`date +%m%d%Y`
if [[ ! -e "./Photos" ]]; then
   mkdir ./Photos
fi

if [[ -e "./Photos/$today/" ]]; then
   echo "./Photos/$today/ exists!"
   increment=1
   echo "checking to see if ./Photos/$today-$increment exists..."
   while [ -e "./Photos/$today-$increment" ]; do
         echo "./Photos/$today-$increment exists!"
         let increment=increment+1
   done
   filename="./Photos/$today-$increment/"
else
   filename="./Photos/$today/"
fi
echo "filename = $filename"
mkdir $filename
cd $filename
num_photos= `gphoto2 --num-files`
num_photos=30
gphoto2 --get-all-files
echo "Downloaded $num_photos pictures to $filename!"
echo "Would you like to remove them from the camera (Y/N)?"
read delete
if [[ $delete == "Y" ]]; then
    gphoto2 --delete-all-files
    echo "Successfully deleted all files."
fi
Edit pathnames, echo's, etc as you like (naturally). As for the "opens the downloaded folder", I wasn't going to put that in there simply because not everyone has an application which will do that (I certainly don't). If you're running Gnome, you could stick a line like

nautilus --no-desktop $filename &

in there at the end, which I think would accomplish the task.
 
Old 08-31-2005, 03:18 PM   #4
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
As an afterthought, the --delete-all-files isn't all that reliable (I thought it was just me that it didn't work for, but google says otherwise).

May I instead substitute something like
gphoto2 --delete-file 0-$num_photos

or, failing even that, put it in a loop:
for i in `seq 0 $num_photos`; do
gphoto2 --delete-file $i
done

I don't remember if they start at 0 or 1, I used 0 for argument's sake.
 
Old 08-31-2005, 03:24 PM   #5
taboom
LQ Newbie
 
Registered: Aug 2005
Distribution: debian sarge (3.1)
Posts: 9

Original Poster
Rep: Reputation: 0
Thank's for the script, I actually already started (or almost finished) coding one myself. The only problems I have are:
- echoed out messages don't appear anywhere
- i'd like to use kde's widgets, like a confirming before deleting, but obviously need to do learn kde coding before this
- I cannot delete with gphoto2 for some reason, it just doesn't delete (even if it succesfully does this command)
- delete-all fails as there is a "theme.dat" on my camera, which is impossible to delete.

On digikam I can delete pictures, but not the theme.dat file

It seems as this is known (deleting the theme.dat file), I remember seeing an error report on this issue somewhere. I have an Ixus 700 and it seems as development for its drivers are also a bit behind currently, but digikam can delete "normal" files!

But thanks fot the script anyway. I'd really be interested in knowing what prog ubuntu uses (I use debian myself)
 
Old 08-31-2005, 03:29 PM   #6
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Yeah, the delete-all-files has a known issue (see my post after that one). You won't be able to use graphical buttons in a bash script; if you want that, just use gtkam (gphoto2's GUI) instead.

The echo'd messages will appear on the commandline, the same place from which you started the script...
Code:
[laura@cleopatra ~/work]$ ./camera.sh
./Photos/08312005/ exists!
checking to see if ./Photos/08312005-1 exists...
./Photos/08312005-1 exists!
./Photos/08312005-2 exists!
./Photos/08312005-3 exists!
./Photos/08312005-4 exists!
filename = ./Photos/08312005-5/
Downloaded 30 pictures to ./Photos/08312005-5/!
Would you like to remove them from the camera (Y/N)?
Y
Successfully deleted all files.
Exiting...
[laura@cleopatra ~/work]$
That's slightly hacked-up, as I don't have my camera plugged in so all of the calls to gphoto2 are commented out and the number of photos is hard-coded, but the meat of the script is still running.

Edit: I see that I left all of the "checking to see if.." debug lines in there. They ought to have been commented out, too. D'oh.

Last edited by rose_bud4201; 08-31-2005 at 03:30 PM.
 
Old 08-31-2005, 03:38 PM   #7
taboom
LQ Newbie
 
Registered: Aug 2005
Distribution: debian sarge (3.1)
Posts: 9

Original Poster
Rep: Reputation: 0
Oh yes, I obviously didnät explain myself..
If I make it start automatically, with hotplug by activating it with files in:
Code:
/etc/hotplug/usb/autocopy.usermap
# Canon Digital IXUS 700
autocopy           0x0003      0x04a9   0x30f2    0x0000       0x0000      0x00         0x00            0x00            0x00            0x00               0x00               0x00000000
and
Code:
/etc/hotplug/usb/autocopy
!/bin/bash
if [ "$ACTION" = "add" ] && [ -f "$DEVICE" ]
then
#do all stuff
---snip--
fi
Now, where does the echoed out messages show? - in a console I never see...
 
Old 08-31-2005, 04:07 PM   #8
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Ohhhh, I see what you mean. Honestly, I'd just use the GUI or run the script manually when you plug the camera in....it's made for running froma commandline, not for background tasks (the fact that you want to give it input means you'll have to run manually). I haven't the faintest idea where output like that goes, but I've a hunch that it's /dev/null. You won't be able to respond to a program like that, either, so you'd better hardcode the deletion of files to either on or off so it doesn't hang waiting for your response.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Have you got a digital camera? Calum Linux - Hardware 19 03-01-2004 03:48 AM
Digital Camera matt3333 Slackware 4 10-05-2003 10:49 PM
what digital camera do i get? skeletal29 Linux - Hardware 6 10-09-2002 10:12 AM
Digital camera NSKL Linux - Hardware 2 09-13-2002 02:58 PM
digital camera athenerx Linux - Software 1 03-08-2002 09:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration