Forums > MaxMSP

alphabetical/numerical sorting…



MIB
June 3, 2007 | 12:42 am

This is probably very basic, and I do appologize, but I am not sure how to handle this.
I have a coll with a bunch of (in this case) pictures in it and would like to arrange them numerically from Pic0.jpeg to Pic33.jpeg. "sort -1 1" doesn’t do what I want it to. What am I missing???
The pics are nicely order in my folder on my desktop but as soon as I read it with the "folder" object, things get scrambled…
Any ideas???

Thanks a bunch.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 266 434 33 196617 clear;
#P message 364 413 53 196617 renumber;
#P message 328 434 52 196617 sort -1 0;
#N coll ;
#T flags 1 0;
#T 0 Pic0.jpg;
#T 1 Pic1.jpg;
#T 2 Pic10.jpg;
#T 3 Pic11.jpg;
#T 4 Pic12.jpg;
#T 5 Pic13.jpg;
#T 6 Pic14.jpg;
#T 7 Pic15.jpg;
#T 8 Pic16.jpg;
#T 9 Pic17.jpg;
#T 10 Pic18.jpg;
#T 11 Pic19.jpg;
#T 12 Pic2.jpg;
#T 13 Pic20.jpg;
#T 14 Pic21.jpg;
#T 15 Pic22.jpg;
#T 16 Pic23.jpg;
#T 17 Pic24.jpg;
#T 18 Pic25.jpg;
#T 19 Pic26.jpg;
#T 20 Pic27.jpg;
#T 21 Pic28.jpg;
#T 22 Pic29.jpg;
#T 23 Pic3.jpg;
#T 24 Pic30.jpg;
#T 25 Pic31.jpg;
#T 26 Pic32.jpg;
#T 27 Pic33.jpg;
#T 28 Pic4.jpg;
#T 29 Pic5.jpg;
#T 30 Pic6.jpg;
#T 31 Pic7.jpg;
#T 32 Pic8.jpg;
#T 33 Pic9.jpg;
#T 34 Pic9.jpg;
#P newobj 328 462 53 196617 coll;
#P newex 379 344 27 196617 t i i;
#P newex 305 401 47 196617 pack 0 s;
#P newex 238 205 40 196617 t b b i;
#P number 238 185 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 192 79 15 0;
#P user umenu 192 259 140 196647 1 2000 275 1;
#X add Pic0.jpg;
#X add Pic1.jpg;
#X add Pic10.jpg;
#X add Pic11.jpg;
#X add Pic12.jpg;
#X add Pic13.jpg;
#X add Pic14.jpg;
#X add Pic15.jpg;
#X add Pic16.jpg;
#X add Pic17.jpg;
#X add Pic18.jpg;
#X add Pic19.jpg;
#X add Pic2.jpg;
#X add Pic20.jpg;
#X add Pic21.jpg;
#X add Pic22.jpg;
#X add Pic23.jpg;
#X add Pic24.jpg;
#X add Pic25.jpg;
#X add Pic26.jpg;
#X add Pic27.jpg;
#X add Pic28.jpg;
#X add Pic29.jpg;
#X add Pic3.jpg;
#X add Pic30.jpg;
#X add Pic31.jpg;
#X add Pic32.jpg;
#X add Pic33.jpg;
#X add Pic4.jpg;
#X add Pic5.jpg;
#X add Pic6.jpg;
#X add Pic7.jpg;
#X add Pic8.jpg;
#X add Pic9.jpg;
#P newex 192 118 76 196617 opendialog fold;
#P newex 192 161 56 196617 folder;
#P message 408 370 14 196617 0;
#P newex 408 344 27 196617 sel;
#P button 379 176 15 0;
#P message 379 221 14 196617 1;
#P toggle 379 244 15 0;
#P newex 379 270 58 196617 metro 100;
#P newex 379 198 49 196617 delay 10;
#N counter;
#X flags 0 0;
#P newobj 379 298 66 196617 counter;
#P fasten 13 2 6 1 273 237 490 237 490 337 430 337;
#P fasten 13 2 0 4 273 240 440 240;
#P fasten 7 0 3 0 413 391 460 391 460 239 384 239;
#P fasten 7 0 0 2 413 388 456 388 456 289 412 289;
#P connect 0 0 15 0;
#P fasten 0 0 6 0 384 321 413 321;
#P fasten 15 0 14 0 384 381 310 381;
#P connect 14 0 16 0;
#P connect 19 0 16 0;
#P connect 17 0 16 0;
#P connect 18 0 16 0;
#P connect 11 0 9 0;
#P connect 9 0 8 0;
#P fasten 15 1 10 0 401 365 505 365 505 255 197 255;
#P connect 8 0 10 0;
#P connect 8 1 12 0;
#P connect 12 0 13 0;
#P fasten 13 0 5 0 243 242 481 242 481 170 384 170;
#P connect 5 0 1 0;
#P connect 1 0 4 0;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 0 0;
#P connect 6 0 7 0;
#P fasten 10 1 14 1 327 284 347 284;
#P window clipboard copycount 20;


jml
June 3, 2007 | 4:18 am

There are two issues:
1. You should be using leading zeros with your incremented pic-names, and be consistent; for ex: pic00.jpg, pic01.jpg, etc. Otherwise (as is the case with OS interpretation), the names get interpreted "out of sequence" when read in.
2. To sort, you can use sort -1 (data in ascending order) followed by "renumber", so:
(messagebox) [sort -1, renumber]
should do the trick for you.

jl

June 4, 2007 | 5:39 am

Martin Ritter schrieb:
> This is probably very basic, and I do appologize, but I am not sure
> how to handle this. I have a coll with a bunch of (in this case)
> pictures in it and would like to arrange them numerically from
> Pic0.jpeg to Pic33.jpeg. "sort -1 1" doesn’t do what I want it to.
> What am I missing??? The pics are nicely order in my folder on my
> desktop but as soon as I read it with the "folder" object, things get
> scrambled… Any ideas???

They are sorted, but alphabetical and not numerical. If you want it
numerical you have to extract the numbers, dump it into a coll, sort it
and then fill the menu…

The suggestion of jl is easier, just name them alphabetically….

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
— _|_)—-|—–()————–
———-()——–www.ccmix.com

June 4, 2007 | 9:51 am

On 3 juin 07, at 02:42, Martin Ritter wrote:

> This is probably very basic, and I do appologize, but I am not sure
> how to handle this.
> I have a coll with a bunch of (in this case) pictures in it and
> would like to arrange them numerically from Pic0.jpeg to
> Pic33.jpeg. "sort -1 1" doesn’t do what I want it to. What am I
> missing???
> The pics are nicely order in my folder on my desktop but as soon as
> I read it with the "folder" object, things get scrambled…

You can extract the number with a simple regular expression. In that
case I’m just looking for a digit "\d" which appears at least once "+".

ej

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 53 63 127 196617 t b s clear;
#P newex 304 150 99 196617 loadmess refer toto;
#P user jit.cellblock 304 177 477 294 3 9 1 1 45 17 0 1 1 0 1 0 1 1 1
0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4
0 0 0;
#P newex 127 176 75 196617 pack 0 s;
#P newex 111 106 91 196617 t s s;
#P newex 111 141 75 196617 regexp (\\d+);
#P newex 111 86 47 196617 zl iter 1;
#P window linecount 2;
#P message 53 198 60 196617 sort -1 -1 , renumber;
#P window linecount 1;
#P message 53 37 135 196617 titi2.aif tutu11.aif toto1.aif;
#N coll toto 1;
#P newobj 127 303 56 196617 coll toto 1;
#P connect 3 0 5 0;
#P connect 5 0 4 0;
#P connect 5 1 6 1;
#P connect 4 1 6 0;
#P connect 6 0 0 0;
#P connect 2 0 0 0;
#P connect 8 0 7 0;
#P connect 9 1 3 0;
#P connect 9 0 2 0;
#P connect 1 0 9 0;
#P fasten 9 2 0 0 174 86 231 86 231 257;
#P window clipboard copycount 10;

Viewing 4 posts - 1 through 4 (of 4 total)

Forums > MaxMSP