Notice that, for this script to work for you, you will have to edit two lines:
1. The source <i>folder</i> where images are to be found.2. The <i>pattern</i> to match, which dictates which image goes to which layer.
Be sure as well to create as many layers as you need. If you don't know, use the <i>getLayer</i> method on the <i>layerset</i> variable, which has the ability to create a new layer when asked to get one for a Z for which a layer doesn't exist yet.