Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using the animation tool Synfig to export a sequence of .png files. These are in the following format: C1.0000.png , C1.0001.png, C1.0002.png and so on.

I want to convert these to a spritesheet (i.e. append all of them together) however, I also need the same animations but flipped.

Here's where I have the problem. When using the following syntax:

 convert C1.*.png -flop C1right.*.png

I don't get a sequence similar to what I had before. (C1right.0000.png, C1right.0001.png etc) but instead C1right.-0.png, C1right.-1.png, etc.

This on its own isn't that bad, but because the +append command sorts the images alphabetically and not numerically, I end up with a sequence where not image 2 follows image 1 but image 11 follows image 1, with 2 ending up after 19.

Is there any way to keep the original file name structure? Or is there a way to ensure that the +append sorts the files numerically?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Only using glob patterns will not do. You must loop on all files:

for f in C1*.png ;do convert $f -flop $(echo $f | sed 's/\./right./') ;done

This will execute like this:

convert C1.01000.png -flop C1right.01000.png
convert C1.01001.png -flop C1right.01001.png
convert C1.01002.png -flop C1right.01002.png
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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