If I have 5 layers, can I export one of those layers as a new file, with a new name, in a new location?

I currently am using "save as" to rename and relocate each layer into 5 new documents.

1 Answer 1


Your problem can be solved by scripting it. You can start by this example. What you should add is closing the document and reopening the old one for exporting all of them.

// this script saves the current doc as a new one (with prompt)
// and removes all layers except for the one
// the user chooses in a dropdown
// main function
var main = function() {
  // if there is no doc
  // abort
  if (app.documents.length === 0) {

  var doc = app.activeDocument; // get the current active doc
  var path = doc.filePath; // get the path

  var name = prompt("Enter a name"); // get a name
  if (name.length === 0) {
    // if the user is to lazy add the date
    name = (new Date()).toString();

  var layernames = [];// to store the layer names
  // loop the layer array
  for (var i = 0; i < doc.layers.length; i++) {
    layernames.push(doc.layers[i].name);// get the name
  // save the doc as a new one
  // under the new name
  doc.save(new File(path + "/" + name + ".indd"));
  // add a small dialog to select the layers
  var diag = app.dialogs.add({
    name: "Layers",
    canCancel: true
  // needs a column for the dropdown
  var column = diag.dialogColumns.add();
  // add the dropdown
  var layerdd = column.dropdowns.add({
    stringList: layernames,
    selectedIndex: 0,
    minWidth: 75
  // show the dialog
  if (diag.show() === true) {
    var ndx = layerdd.selectedIndex;// get the index
    diag.destroy(); // remove dialog
    // move the layer to top
    // remove all other layers
    for (var j = doc.layers.length - 1; j >= 1; j--) {
  // THE END
main(); // run that thing    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.