0

I have many pictures which I want to make a movie from. The problem is that they don't follow a regular numeric order. They came from my smartphone camera, but some were captured in the same second, so their names are (for instance):

20180708_173141.jpg
20180708_173142.jpg
20180708_173142(0).jpg
20180708_173143.jpg
20180708_173145.jpg

I think I should do something like

avconv -r 10 -i 20180708_%06d.jpg test.avi

but I can't use 20180708_%06d.jpg, because the third file above would be ignored. I tried using

avconv -r 10 -i 20180708*.jpg test.avi

but it says the second file on the list already exists, asking me if I want to overwrite it.

What should I do?

EDIT: I'm using Linux Debian 9 (Stretch) 64-bit.

  • In Windows, just make a copy (put originals somewhere safe) of all the files, pick them in the order you want, and in Explorer, select Rename. If you leave the original field blank, they'll be named (1).jpg, (2).jpg etc. See howtogeek.com/111859/… – DrMoishe Pippik Jul 9 '18 at 1:21
  • @DrMoishePippik Sorry, I forgot to mention I'm using Linux, edited the question to address this. Your solution will create files with a variable number of digits, (1), (2)... (9), (10), (11)... (99), (100), (101)... I think avconv will still have problems with that. – Rodrigo Jul 9 '18 at 3:38
  • BTW, the Windows program IrfanView (which runs nicely in wine... it's one of the very few Windows executables I use on Linux) has batch renaming which can specify a fixed-length format such as 0001.jpg, 0002.jpg etc. – DrMoishe Pippik Jul 9 '18 at 14:36
  • @DrMoishePippik Thank you. Yesterday I ended up creating a bash script. See the answer I posted. – Rodrigo Jul 9 '18 at 15:03
0

I've created a bash script to rename all files numerically (from here).

EII=1
for i in $(ls *.jpg)
do
  NEWNAME=IMG_`printf "%3d" $EII`.JPG
  mv $i $NEWNAME
  EII=`expr $EII + 1`
done

Then I could apply

avconv -r 10 -i IMG_%3d.jpg test.avi
| improve this answer | |
  • Still one question remains: if I needed to change the position of some images, let's say, move the 030 to between 040 and 041, I could rename it to 040a, but then how would avconv treat this? Or should I rename all files between 030 and 040, so that the moved image could fit into place? I really can't use wildcards like * ? – Rodrigo Jul 9 '18 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.