Updating camera settings with gphoto2

gphoto2 is a cool little command line utility to remotely control many digital cameras and their settings.  Grab it out of your repository, connect your camera by USB, turn on and enjoy.

Sometimes when you try to use gphoto2 you get an error message like this

*** Error ***              
An error occurred in the io-library ('Could not lock the device'): Camera is already in use.
*** Error (-60: 'Could not lock the device') ***

which is probably because you’ve connected you camera with an SD/CF card in it.  Fix it simply with

 gvfs-mount -s gphoto2

or however you chose to unmount a remote drive.

All I wanted to do was check my shuttercount, but you can get a full list of your camera’s capabilities with the following command (yours will probably be different)

simon@commodus:~$ gphoto2 --list-config

and to get the current setting for any one key (you can use either the short or long key), just

simon@commodus:~$ gphoto2 --get-config shuttercounter
Label: Shutter Counter                                                         
Type: TEXT
Current: 66666

I thought I’d update the time on the camera whilst I was at it, so used this handy little shortcut.

gphoto2 --set-config datetime=`date +%s`

Depending on your model, you may be able to set copyright and ownername strings which the camera will automatically embed in EXIF for all photos taken: check what your camera supports as described above.