473,237 Members | 1,067 Online

Sequential file numbering...

Hey all:

Slightly off topic...

If I have a series of images that I want to convert to an animated gif
using the command line tool 'convert' from imagemagick, they cannot be
named:

1
2
3
4
5
6
7
8
9
10
11
Because this is seen as:

1
10
11
2
3
4
5
6
7
8
9

So I am trying to write a PHP script that will sequentially convert and
number a series of images, and I won't know ahead of time how many will
be in a given sequence. This files are originally randomly numbered,
but the sequence information can be extracted, and their order
determined. I then want to rename them, and I'm thinking I should use:

01
02
03
04
05
06
07
08
09
10
11

This works, and I guess I'll just need to tally the number of images,
and figure out if the 'lefthand' zeroes should be taken to the hundreds
and thousands place.

Anyone else know a simpler way around this problem?

-cjl

Jul 17 '05 #1
1 1534
"cjl" <cj****@gmail.com> wrote in message
Hey all:

Slightly off topic...

If I have a series of images that I want to convert to an animated gif
using the command line tool 'convert' from imagemagick, they cannot be
named:

1
2
3
4
5
6
7
8
9
10
11
Because this is seen as:

1
10
11
2
3
4
5
6
7
8
9

So I am trying to write a PHP script that will sequentially convert and
number a series of images, and I won't know ahead of time how many will
be in a given sequence. This files are originally randomly numbered,
but the sequence information can be extracted, and their order
determined. I then want to rename them, and I'm thinking I should use:

01
02
03
04
05
06
07
08
09
10
11

This works, and I guess I'll just need to tally the number of images,
and figure out if the 'lefthand' zeroes should be taken to the hundreds
and thousands place.

Anyone else know a simpler way around this problem?

-cjl

Use natcasesort() to sort the list.

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.