Image scripting..

Home Forums InDesign User Groups Image scripting..

This topic contains 17 replies, has 4 voices, and was last updated by  Sayed Mohammed 5 months ago.

  • Author
  • #103086


    Is there any script to keep images on one layer on indesign?

    Thanks to all

    Sayed Mohammed

  • #103102

    Erica Gamet

    Do you already have the images on the page? You can select them all, then move the little colored proxy in the Layers panel to the layer you want to put them on.

  • #103103

    David Blatner

    There is no way to keep them on one layer, but perhaps there could be a script to move them all to one layer. This script is similar, but it works on buttons:

  • #103137

    Erica Gamet and David Blatner
    I would like to say something on this occasion, which is that I learned a lot from you, otherwise I would not have been able to complete many of the publications I have produced …

    Sayed MOhammed ali
    Accept my greetings

  • #103138


    If you talk about all the not-anchored images in the doc, a simple 2-code-lines script will be enough! ;-)

    Michel, from FRIdNGE

  • #103139

    David Blatner

    Sayed, I’m very happy that we have been able to be helpful to you!

    Michel, do you wish to share your two lines of code?

  • #103140


    var myLinks = app.activeDocument.links, L = myLinks.length;
    while ( L– ) if ( myLinks[L] != “Character” && myLinks[L] != “Layer 1” ) myLinks[L].parent.parent.itemLayer = “Layer 1”;

    … But there’re really 2 lines!

    I prefer this personal version [alert messages with counter + FRIdNGE logo + sku, global undo]!

    … Really more expansive than “for free”, just because there’re 92 code lines! =D

    Michel, from FRIdNGE

  • #103143

    David Blatner

    Michel, when you post code here, please use a the code html tag, or else the code get messed up (curly quotes, etc.)

    However, I tried to clean this up and it still does not work for me:

    var myLinks = app.activeDocument.links, L = myLinks.length;
    while ( L– ) if ( myLinks[L] != "Character" && myLinks[L] != "Layer 1" ) myLinks[L].parent.parent.itemLayer = "Layer 1";

    I am getting an error that says: ) does not have a value and the offending text is )

  • #103146

    Hi David,

    Change: while (L–)

    html tag?


  • #103147

    Grrrr! …Thanks to type 2 en-dashs!

  • #103148

    David Blatner

    Ah ha! Mercí! (Or is it mercì?)

    OK, now there is no syntax error, but the script does not move any of my images to a different layer. Should the following move all the images to Layer 2?

    var myLinks = app.activeDocument.links, L = myLinks.length;
    while (L--) if (myLinks[L] != "Character" && myLinks[L] != "Layer 1") myLinks[L].parent.parent.itemLayer = "Layer 2";

  • #103149

    Not my day! … but not yours too! =D

    The Script checks all the images: as indicated, if not on “Layer 1”, they are moved on it!


  • #103152

    Of course, the Script checks if the image is “anchored”! If not, it can move it! ;-)
    We could add more checkings as if it’s a .pdf file or a .png file …


  • #103153

    David Blatner

    Thank you, Michel! OK, I see my mistake. This script works if the layer is called “images” — of course, you can change that to any other layer name, but it must be changed in 2 places in the script.

    var myLinks = app.activeDocument.links, L = myLinks.length;
    while (L--) if (myLinks[L] != "Character" && myLinks[L] != "images") myLinks[L].parent.parent.itemLayer = "images";

    I understand that you have written a more robust script that can do much more, and does error checking (and that people can pay you for that version). But thank you for sharing this simple free version.

  • #103154

    “… Pour vous servir, Monseigneur !” [in French]


  • #103166

    I would like to thank everyone who helped and answered the previous question, and I wish that if Mr. David take a snapshoot of the script and how use in th grib (on find and change).

    thanks again….
    Sayed MOhammed

  • #103168

    David Blatner

    HI Sayed, here is an article about how to run scripts:

    How to Install a Script in InDesign That You Found in a Forum or Blog Post

  • #103259

    thanks Mr. David Blatner

You must be logged in to reply to this topic.