Hi Rick,

On the basis that this is quite likely something simple that I'm not doing, or the consequence of something I haven't explained clearly enough (as I've very little experience with such things) -

These are the files I'm working with:

four sets of 124 images each:

a_000001.jpeg to a_000125.jpeg
b_000001.jpeg to b_000125.jpeg
c_000001.jpeg to c_000125.jpeg
d_000001.jpeg to d_000125.jpeg

I've entered the command:

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

and receive the response:
bash: syntax error near unexpected token `do'

(I've cut-and-pasted the information for accuracy)

I've also tried changing:

'seq 1 999'
to
'seq 1 125'

with no success and tried changing:

do j='printf %04d
to
do j='printf %06d

again with no success.

I'm wondering if you wouldn't mind having another look at this for me?

Thanks again and much appreciated.

Regards,

Patrick



Rick Welykochy wrote:
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






--
Registered GNU/Linux User 368634
--
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