Rename Images with chdkptp - Script Writing - CHDK Forum

Rename Images with chdkptp

  • 2 Replies
  • 2248 Views
Rename Images with chdkptp
« on: 03 / March / 2021, 18:15:15 »
Advertisements
Is it possible to rename images when downloading them from the camera with chdkptp?

Code: [Select]
chdkptp.sh -c-d=022 -e=imdl-rm
I am writing a bash script for my DIY book scanner. I have two cameras and earlier in the script I snap a series of images. I then download them all. As of now the images are downloaded into two separate directories, from the respective cameras.

I do it like this:

Code: [Select]
camlist=$(./chdkptp.sh -e=list)
for getcamnum in $camlist
do
if [[ "$getcamnum" == *"d="* ]]
  then
  devnum=$getcamnum
echo Downloading images from camera $devnum
  ./chdkptp.sh -c-$devnum -e=imdl-rm
fi
done

Is there a way to collate the images into one folder and rename them sequentially?

Something like img001.jpg, img002.jpg, img003.jpg OR img001_l.jpg, img001_r.jpg, img002_l.jpg, img002_r.jpg, etc for the left and right pages.

I guess I could mv them all after downloading, but I was wondering if there is something built into chdkptp to do it from the command line.


*

Offline reyalp

  • ******
  • 14117
Re: Rename Images with chdkptp
« Reply #1 on: 04 / March / 2021, 02:34:22 »
Is it possible to rename images when downloading them from the camera with chdkptp?
...

Something like img001.jpg, img002.jpg, img003.jpg OR img001_l.jpg, img001_r.jpg, img002_l.jpg, img002_r.jpg, etc for the left and right pages.
Yes, you can use the -d option to name the images. There are various "substitution variables" you can use to set the name. Try "help imdl" for all the details.

If you want sequential numbers for each session, you can use ${dlseq}, like
Code: [Select]
imdl -rm -d=img_${dlseq}_r${ext}

Note you'll want to protect the $ from the shell if you are using it in a bash script rather than just in the chdkptp prompt, like
Code: [Select]
-e'imdl -rm -d=img_${dlseq}_r${ext}'
If your bash script identifies the left and right cams, you can do separate versions of the above the r and l.

edit:
if you want to include devnum from your bash script, you can just put it outside the single quotes, like
Code: [Select]
-e'imdl -rm -d=img_'$devnum'_${dlseq}_r${ext}'

You can set the starting number for ${dlseq} with the -seq option.

You can use ${shotseq} instead of dlseq if you want jpeg and dng of the same shot to use the same number.

You can use -pretend to show what would be done without actually downloading everything.
« Last Edit: 04 / March / 2021, 02:47:40 by reyalp »
Don't forget what the H stands for.

Re: Rename Images with chdkptp
« Reply #2 on: 04 / March / 2021, 19:18:01 »
Thank you so much. That was exactly what I needed to know. Works great.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal