#9 copy photos from USB PTP and rename with exiftool and compress

How to copy photos from USB PTP camera?

If the camera is connecting to computer by USB and has set as a USB device, then we can copy those photos by gphoto2 and gphotofs.

You might need to unmount from a file manager if automounted as we need to Make sure no other program (gvfs-gphoto2-volume-monitor) or kernel module (su ch as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.

#sudo apt  install gphoto2 gphotofs

Look around

#gphoto2 --summary
#gphoto2 --auto-detect
#gphoto2 --list-ports
#gphoto2 --list-cameras
#gphoto2 --list-folders
#gphoto2 --abilities

There is 1 folder in folder '/'.
 - store_10000001
There is 1 folder in folder '/store_10000001'.
 - DCIM
There is 1 folder in folder '/store_10000001/DCIM'.
 - 129_FUJI
There are 0 folders in folder '/store_10000001/DCIM/129_FUJI'.

Make a directory for mounting USB PTP camera

#mkdir /home/kusanagi/usbptp/

Mount USB PTP to the directory

#gphotofs /home/kusanagi/usbptp/

Copy photos which was created today to current directory

#find ~/usbptp/store_10000001/DCIM/129_FUJI/ -daystart -mtime 0 -exec sh -c "cp {} ." \;

Rename photos with exiftool

Today is 20230402.

#sudo apt install libimage-exiftool-perl

#mkdir /media/kusanagi/toshiba-pc-l200-1/20230402{,-smallres}/

#exiftool '-FileName<${CreateDate}_${Exif:Model}_${filename}' -d %Y%m%d_%H%M%S -v1 *

Generate smaller resolution photos for sharing / backup

#find . -iname "*jpg" -exec sh -c  "mogrify -path /media/kusanagi/toshiba-pc-l200-1/20230402-smallres/ -quality 95  -resize 1440x1440  {} " \;
#find . -iname "*jpg" -exec sh -c  "mogrify -path /media/kusanagi/toshiba-pc-l200-1/20230402-smallres/ -quality 95  -resize 1440x1440  {} " \;

Done, unmount gphotofs

fusermount -u /home/bob/usbptp