This script renames all layers in the active document, including those within groups. The script prompts for a layer name pattern, and then renames and numbers the layers.
Note: This script also contains user-customizable variables (near the top of the script) for configuring the starting count (default is 1), zero-padding (default is 3), name separator (default is a space), and direction (default is top to bottom).