Perhaps ask in the scripting forum. There is no way to do it otherwise.
Thank you Bob, Let me check in the scripting forum.
Create 1 version of the layers in a file.
Put an item on each layer.
Once you have this done, you can copy and paste the items into another file.
In the layers panel sub men (top right of panel) choose Paste Remembers Layers.
All the layers should Auto-Generate with the new layers.
Doesn't have to be much.
Setup a text frame on the bottom layer. Then alt key and drag the square in the layers panel to the other layers.
Once you select that area by drawing a marquee you'll select all objects on every layer.
Then you delete them once pasted into the new doc.
Hope that helps.
Thank you Eugene, I have tried this steps but we require more than this. Layer assignment in our task is dynamic.
As the layer names are dynamic(this changes from document to document) we have a template with generic layers - lets say "Layer 1" to "Layer 20" these are hooked to a database system which brings data in different layers.
Once data is in, we now have generic layers with actual values. We have a excel sheet which holds this information on "From-->To" information and the only option left for is to rename it manually.
This renaming is important because we have an application which creates separate documents for each layers based on the layer name provided and If we still use generic name we will have a mess with different documents because the names are generic (Layer 1 to 20) in all my document.