If you want to rebuild all of the indexes then you don't need a script; it's a one-liner. For example:
proutil dbname -C idxbuild all [other idxbuild parameters...]
Read the 10.1C docs to see which parameters are available to you. It's not much unfortunately. Note that idxbuild performance was significantly enhanced with the addition of new algorithms, and parameters to enable them, in later 10.2B service packs (mainly 10.2B06). If minimizing downtime is at all a concern for you, you should look into using 10.2B06 or later for your idxbuild.
What the values for [other idxbuild parameters...] should be is up to you. These parameters govern the use of system resources (e.g. CPU cores, RAM, disk space) and may be limited by the OS limits for your user (e.g. file handles). If you set these parameters incorrectly and your idxbuild process crashes, this sets the "tainted" flag in the database and you have to restore from backup. Therefore, if your database contains any data that you care about, always take a full backup of your database before running an idxbuild.