Skip to main content
Audrey12345
Participant
June 20, 2014
Answered

Script to move all text objects to another Layer

  • June 20, 2014
  • 2 replies
  • 1109 views

Hi ,

I need a script that moves all text objetcs to another layer.

The layer is already created, i managed to access the text objects.

How can i move them to a specific layer ?

Thanks

Audrey

for(var e = 0;e<doc.textFrames.length;e++){

    var frame =  doc.textFrames;

WRITE HERE HOW TO MOVE TO ANOTHER LAYER

            

       }

This topic has been closed for replies.
Correct answer pixxxelschubser

Hi audrey12345,

for things like this it's very important, where your destination layer is.

 

If your destination layer is above all other layers (with text frames) you can loop "e++" like this:

 

var doc = app.activeDocument;
var Layer2Move = doc.layers.getByName ("YourLayerName");
for( e = 0;e <= doc.textFrames.length-1;e++) {
    doc.textFrames[e].moveToEnd(Layer2Move);
}
 

 

If not, you have to loop backwards "e--".

If destination layer is between other layers - this method is unsuitable.

 

Have fun

2 replies

Mike Witherell
Community Expert
Community Expert
January 24, 2023

Is there an update for the above question that works in January 2023?

Mike Witherell
Disposition_Dev
Legend
January 24, 2023

Here you go. When the forums migrated recently, a lot of old posts that included code snippets mysteriously had the brackets and index variables removed from loops..

var doc = app.activeDocument;
var Layer2Move = doc.layers.getByName ("YourLayerName");
for( e = 0;e <= doc.textFrames.length-1;e++) {
    doc.textFrames[e].moveToEnd(Layer2Move);
}
Mike Witherell
Community Expert
Community Expert
January 24, 2023

Thank you so much! Just what I needed.

Mike Witherell
Audrey12345
Participant
June 20, 2014

Using javascript please.

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
June 20, 2014

Hi audrey12345,

for things like this it's very important, where your destination layer is.

 

If your destination layer is above all other layers (with text frames) you can loop "e++" like this:

 

var doc = app.activeDocument;
var Layer2Move = doc.layers.getByName ("YourLayerName");
for( e = 0;e <= doc.textFrames.length-1;e++) {
    doc.textFrames[e].moveToEnd(Layer2Move);
}
 

 

If not, you have to loop backwards "e--".

If destination layer is between other layers - this method is unsuitable.

 

Have fun