Forum Moderators: coopster

Message Too Old, No Replies

iterating over directory with pointer?

         

belfasttim

11:04 pm on Jan 19, 2010 (gmt 0)

10+ Year Member



Hi--

I have some large directories (some with nearly 100,000 files in them). They're all images, and I need to do some stuff to them (resize, move etc.)

I am quite sure the number of elements is too large for reading the directory contents into an array and playing with them that way. And since I want to handle each file only once, what I'm looking for is a way to read out maybe the first 250-500 files, manipulate them, then continue with the next 250 and so on. I'd like to do them in batches like this because I'm going to use multi-curl to move them, and I am again pretty sure I can't do a multi-curl request with 100k items all at once.

Is anyone aware of a way to do an iterator with a pointer, so to speak? So I can read X number of items, do something with them, then return to the pointer where I left off and read the next X number of items?

Thanks for any ideas.

IanKelley

2:57 am on Jan 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



[php.net...]

Each call increments the pointer.

belfasttim

3:28 am on Jan 20, 2010 (gmt 0)

10+ Year Member



Thanks Ian-- that looks like the ticket. In the meantime I'd learned quite a bit about the directoryIterator class, but this might work better.

Thanks again