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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-31-2005, 02:14 PM
|
#1
|
LQ Newbie
Registered: Aug 2005
Distribution: debian sarge (3.1)
Posts: 9
Rep:
|
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
|
|
|
08-31-2005, 02:41 PM
|
#2
|
Member
Registered: Aug 2003
Location: Illinois
Distribution: Linux Mint XFCE
Posts: 654
Rep:
|
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
|
|
|
08-31-2005, 03:08 PM
|
#3
|
Member
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929
Rep:
|
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.
|
|
|
08-31-2005, 03:18 PM
|
#4
|
Member
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929
Rep:
|
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.
|
|
|
08-31-2005, 03:24 PM
|
#5
|
LQ Newbie
Registered: Aug 2005
Distribution: debian sarge (3.1)
Posts: 9
Original Poster
Rep:
|
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)
|
|
|
08-31-2005, 03:29 PM
|
#6
|
Member
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929
Rep:
|
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.
|
|
|
08-31-2005, 03:38 PM
|
#7
|
LQ Newbie
Registered: Aug 2005
Distribution: debian sarge (3.1)
Posts: 9
Original Poster
Rep:
|
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...
|
|
|
08-31-2005, 04:07 PM
|
#8
|
Member
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 02:50 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|