Re: [SLUG] looking for a command to automatically create sequentially numbered files

2008-04-13 Thread Peter Chubb
> "elliott-brennan" == elliott-brennan  <[EMAIL PROTECTED]> writes:

elliott-brennan> Hi all,

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

elliott-brennan> I have a collection of images labelled -

elliott-brennan> a_0001.jpeg through to A0999.jpeg b_0001.jpeg through
elliott-brennan> to A0999.jpeg c_0001.jpeg through to A0999.jpeg
elliott-brennan> d_0001.jpeg through to A0999.jpeg

elliott-brennan> I want to merge them as follows:

elliott-brennan> montage -geometry +4+4 a_0001.jpeg b_0001.jpeg
elliott-brennan> c_0001.jpeg d_0001.jpeg montage1.jpeg

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

You need to do it one number at a time.

for i in `seq -f '%04.f' 1 999`
do
montage  -geometry +4+4 {a,b,c,d}_$i.jpeg montage$i.jpeg
done


I'm not sure about the best way to do the _ to A series though.

A simplish way would be:
for file in a*
do
num=`expr "$file" : "a\(.*\)\.jpeg"`
montage -geometry +4+4  {a,b,c,d}$num.jpeg montage$num.jpeg
done

but this preserves the _->A sequence, so you'll end up with
montage_0001.jpeg through to montageA999.jpeg.

If you want to replace the _->A with 0->whatever you need a tr line in
there:

for file in a*
do
num=`expr "$file" : "a\(.*\)\.jpeg"`
outnum=`echo $num | tr '_A' '01'`
montage -geometry +4+4  {a,b,c,d}$num.jpeg montage$outnum.jpeg
done

Use your collating  sequence, as I don't know what it is ('_' comes
after 'A' in ASCII).


--
Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au   ERTOS within National ICT Australia
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] looking for a command to automatically create sequentially numbered files

2008-03-10 Thread Amos Shapira
On Sat, Mar 8, 2008 at 1:07 PM, Felix Sheldon <[EMAIL PROTECTED]> wrote:
>
>  It looks like you might be using single quotes and not back-ticks (on
>  the ~ key).
>
>  This works for me, with the echo in there at least.
>
>  for i in `seq 1 125`; do j=`printf %06d $i`; echo montage -geometry +4+4
>
> a_$j.jpeg b_$j.jpeg c_$j.jpeg d_$j.jpeg montage$j.jpeg; done

BTW - you can do away with "printf" and tell seq itself to format the
output using "-f %06g".

Notice that "seq" only accepts "f", "e" or "g", not "d".

So the above will translate to:

for j in `seq -f %06g 1 125`; do echo montage -geometry +4+4 a_$j.jpeg
b_$j.jpeg c_$j.jpeg d_$j.jpeg montage$j.jpeg; done

Cheers,

--Amos
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] looking for a command to automatically create sequentially numbered files

2008-03-08 Thread Sridhar Dhanapalan
On Sun, 9 Mar 2008, Alex Samad <[EMAIL PROTECTED]> wrote:
> On Sun, Mar 09, 2008 at 12:07:45AM +1100, Felix Sheldon wrote:
> > It looks like you might be using single quotes and not back-ticks (on
> > the ~ key).
> >
> > This works for me, with the echo in there at least.
> >
> > for i in `seq 1 125`; do j=`printf %06d $i`; echo montage -geometry +4+4
> > a_$j.jpeg b_$j.jpeg c_$j.jpeg d_$j.jpeg montage$j.jpeg; done
>
> you can also use $( some-command )

Which can be better as you can nest commands, like so:

  $($(command1)command2)


-- 
 "We like to think of ourselves as the Microsoft of the energy world"
- Kenneth Lay, former CEO of Enron


signature.asc
Description: This is a digitally signed message part.
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Re: [SLUG] looking for a command to automatically create sequentially numbered files

2008-03-08 Thread Alex Samad
On Sun, Mar 09, 2008 at 12:07:45AM +1100, Felix Sheldon wrote:
>
> It looks like you might be using single quotes and not back-ticks (on  
> the ~ key).
>
> This works for me, with the echo in there at least.
>
> for i in `seq 1 125`; do j=`printf %06d $i`; echo montage -geometry +4+4  
> a_$j.jpeg b_$j.jpeg c_$j.jpeg d_$j.jpeg montage$j.jpeg; done
you can also use $( some-command )

>
> -- 
> Felix
>
>
> elliott-brennan wrote:
>> 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_01.jpeg to a_000125.jpeg
>> b_01.jpeg to b_000125.jpeg
>> c_01.jpeg to c_000125.jpeg
>> d_01.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 montage1.jpeg

 the output file is montage.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
>>>
>>>
>>>
>>>
>>>
>>
>
> -- 
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>

-- 
"One thing is clear, is relations between America and Russia are good, and 
they're important that they be good."

- George W. Bush
07/15/2006
Strelna, Russia


signature.asc
Description: Digital signature
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Re: [SLUG] looking for a command to automatically create sequentially numbered files

2008-03-08 Thread Felix Sheldon


It looks like you might be using single quotes and not back-ticks (on 
the ~ key).


This works for me, with the echo in there at least.

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


--
Felix


elliott-brennan wrote:

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_01.jpeg to a_000125.jpeg
b_01.jpeg to b_000125.jpeg
c_01.jpeg to c_000125.jpeg
d_01.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 montage1.jpeg


the output file is montage.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









--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] looking for a command to automatically create sequentially numbered files

2008-03-08 Thread elliott-brennan

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_01.jpeg to a_000125.jpeg
b_01.jpeg to b_000125.jpeg
c_01.jpeg to c_000125.jpeg
d_01.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 
montage1.jpeg


the output file is montage.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


Re: [SLUG] looking for a command to automatically create sequentially numbered files

2008-03-07 Thread Rick Welykochy

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 
montage1.jpeg


the output file is montage.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


[SLUG] looking for a command to automatically create sequentially numbered files

2008-03-07 Thread elliott-brennan

Hi all,

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 montage1.jpeg


the output file is montage.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.


Regards,

Patrick

--
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


[SLUG] looking for a command to automatically create sequentially numbered files

2008-03-07 Thread elliott-brennan

Hi all,

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 montage1.jpeg


the output file is montage.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.


Regards,

Patrick

--
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