elliott-brennan wrote:

Now, I know I've asked a similar questions, but I thought that I'd ask again with what may be a clearer request :)))))
For example:

I have a collection of images labelled -

a_0001.jpeg through to A0999.jpeg
b_0001.jpeg through to A0999.jpeg
c_0001.jpeg through to A0999.jpeg
d_0001.jpeg through to A0999.jpeg

I want to merge them as follows:

montage -geometry +4+4 a_0001.jpeg b_0001.jpeg c_0001.jpeg d_0001.jpeg montage00001.jpeg

the output file is montage<number>.jpeg and needs to be a sequentially increasing number.

Is there a command that will allow me to do this automatically without having to individually enter each file name and output name?

I realise this is a little weird and no doubt unusual, but, as usual, any assistance or direction would be most appreciated.

Not weird at all. Well organised file systems often use sequential
or semi-sequential numbering to keep things logical and consistent.
(Who said consistency is the last refuge of the unimaginative?)

The GNU seq command is useful for sequential numbering.

$ seq 1 5
1
2
3
4
5

As well, you can use printf to format the numbers as you wish, e.g.

$ for i in `seq 1 5`; do echo `printf a_%04d.jpeg $i`; done
a_0001.jpeg
a_0002.jpeg
a_0003.jpeg
a_0004.jpeg
a_0005.jpeg

Putting it all together:

$ for i in `seq 1 5`; do j=`printf %04d $i`; echo montage -geometry +4+4 a_$j.jpeg b_$j.jpeg c_$j.jpeg d_$j.jpeg montage$j.jpeg; done

montage -geometry +4+4 a_0001.jpeg b_0001.jpeg c_0001.jpeg d_0001.jpeg 
montage0001.jpeg
montage -geometry +4+4 a_0002.jpeg b_0002.jpeg c_0002.jpeg d_0002.jpeg 
montage0002.jpeg
montage -geometry +4+4 a_0003.jpeg b_0003.jpeg c_0003.jpeg d_0003.jpeg 
montage0003.jpeg
montage -geometry +4+4 a_0004.jpeg b_0004.jpeg c_0004.jpeg d_0004.jpeg 
montage0004.jpeg
montage -geometry +4+4 a_0005.jpeg b_0005.jpeg c_0005.jpeg d_0005.jpeg 
montage0005.jpeg

Get rid of the "echo" command, change 5 to 999 and Bob's your aunty.


cheers
rickw





--
________________________________________________________________
Rick Welykochy || Praxis Services || Internet Driving Instructor

When I was a kid I used to pray every night for a new bicycle. Then I realized
that the Lord doesn't work that way so I stole one and asked Him to forgive me.
     -- Emo Phillips
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to