You can iterate through the $ibl and $chan identifiers using nested WHILE loops.
I would explain this further, but I make it a personal point to allow users to figure out "mass-scripts" for themselves. This is not a newbie-level script, and should be left to users who already know what they're doing... as such scripts can easily be disruptive to other users if written or used improperly.
Writing such scripts also tends to require methods of evading server flood limits. This varies from network to network and server to server, so a one size fits all script will be difficult at best. You will require knowlege of your own server's limits and tolerance.
- Raccoon