Moving graphics and texts to separate the layers on multiple open documents

Hello world

My situation is as follows:

I have several documents to make changes to, and I can't have my script to work on all open documents.

I get an error message:

2015-07-30_12h12_09.png

My script works only on a single file, and then stops with this error.

What I'm doing:


I would spend all my texts to a certain layer, which is created by the script and move all my photos to a different layer, also created by the script. (the graphics must be only graphic, not rectangles with a fillColor, but of the rectangles with graphics inside of them.)

I'm trying to make this happen on all open documents.

I also want to get rid of all the other layers, except the two I've created with the script.

Why am I doing this?

Well, I have documents with images and texts, but also some rectangles filled with colors.

I'm trying to get rid of these rectangles, but I have found no way to get rid of the rectangles without getting rid of the rectangles that have images inside them...

Here's the code I'm working on:

function moveToLayer(){    
 var myDoc = app.documents;

        for (var i = myDoc.length-1; i >= 0; i--) {
            
if(!myDoc[i].layers.itemByName("pictureLayer").isValid){myDoc[i].layers.add({name:"pictureLayer" })}; 
if(!myDoc[i].layers.itemByName("textLayer").isValid){myDoc[i].layers.add({name:"textLayer"})}; 

var textLayer = myDoc[i].layers.itemByName("textLayer"); 
textLayer.locked = false; 

var pictureLayer = myDoc[i].layers.itemByName("pictureLayer"); 
pictureLayer.locked = false; 

myDoc[i].spreads.everyItem().textFrames.everyItem().locked = false; 
myDoc[i].spreads.everyItem().textFrames.everyItem().itemLayer = textLayer; 

var myPageItems = myDoc[i].pageItems;  

for(var i=0; i<myPageItems.length; i++){  
    
if(myPageItems[i].allGraphics.length==1){
    
myPageItems[i].locked = false; 
myPageItems[i].itemLayer = pictureLayer; 
}
}
}
}

I've been everywhere in the forum to research, gather a few pieces of code, but now I'm stuck and begging for your help!

Could someone please explain me what is happening and what is wrong, and/or could get this script to work as it should?

Thank you all!

Embeddd of the loop for use the same variable for the meter, i. use a different variable for integrated loop:

for(var j=0; j

and change all the i-j inside this loop.

Peter

Tags: InDesign

Similar Questions

  • The device icon and text missing in the imaging devices Manager

    The device icon and text missing in the imaging devices Manager

    I'm running MS Vista Ultimate.

    The imaging device icon and the wording are missing in Device Manager are missing. A device is listed in the box as installed missing icon.

    The other devices in Device Manager normally appear and I can compare what is supposed to be there for another computer running the same version of windows.

    However, the device will not work and will not reinstall.

    When you try to reinstall the device an error indicates that Setup does not work and to contact the manufacturer of the device.

    Yet once, however, this happens when I try to install any imaging device.

    I'm unable to locate information about the imaging devices in the registry.

    I think that some registry entries are missing.

    It is not the missing peripheral individual. This is the section in Device Manager.

    The image error is logged:

    "Windows didn't load setup." Contact your hardware vendor. »

    This happens with any device inaging of anyone.

    Hi henrymullersr

    What imaging device do you use?

    We can try a few steps and check if it helps you.

    Try to run the hardware and devices Troubleshooter: http://windows.microsoft.com/en-US/windows7/Open-the-Hardware-and-Devices-troubleshooter

    If the result of the Troubleshoot utility is negative, then reinstall the device. And also be sure to uninstall the previous contents of the device driver by running utility windows install cleanup:

    http://download.Microsoft.com/download/e/9/d/e9d80355-7ab4-45b8-80e8-983a48d5e1bd/msicuu2.exe

    Now follow the following steps:

    1. Save the Windows Installer Cleanup Utility package on your computer

    2. right click on the Windows Installer Cleanup Utility and run as administrator

    3. follow you prompt in the installation wizard. Once completed the installation, click on the Start button

    4. click on all programs. Click on Windows Install CleanUp Utility.

    5. click on the device driver (if on list) in the list of programs.

    6. click on Remove. Click OK

    7. click exit

    Restart the computer for the changes to take effect
     
    Then try to install the device driver and check the result: http://windows.microsoft.com/en-US/windows-vista/Install-a-USB-device

    After back and let us know if it helped to solve your problem.

    Thank you and best regards,

    R uma - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • I prefer SEPARATE (for multiple open documents) instead of tedious proceedings hover over the icon and then choose the one I want.

    Notepad or WORD or EXCEL, Lotus SAMETIME, I prefer SEPARATE (for multiple open documents) instead of tedious proceedings hover over the icon and then choose the one I want.  I can't figure out how to change that, and it's a boring true change to XP. Does anyone know how to do this?

    Go to the Start menu button, right-click on it, select Properties, click the task bar .

    Click the drop-down list buttons Taskbar & select never combine.

    That's all.  You should now see an entry of the separate taskbar for each open file on your PC.

  • Mac OS 10.6.8 - Photoshop CS5.1 after years of perfect use, suddenly I'm unable to select a layer by clicking on the image and select it in the layers palette.  Solve this problem for me and I'll buy you a new car.  With our thanks, David Heidelberge

    Mac OS 10.6.8 - Photoshop CS5.1

    After years of perfect use, suddenly I can't select a layer by clicking on the image and select it in the layers palette.

    Solve this problem for me and I'll buy you a new car.

    With our thanks, David Heidelberger

    Hi David

    Have you checked your settings to automatic selection in the upper left of the workspace?

  • There is text on my photo, but there is no text layer in the layers panel. What is everything?

    There is text on my photo, but there is no text layer in the layers panel. What is everything?

    Hi juliannz,

    The layers panel will contain the text only if you have saved the original under a PSD file.

    If it was saved as a jpeg, png, it not the layers.

  • In order to improve my skills and ease with Premiere Pro, I bought Adobe Premiere Pro CC Classroom in a Book and began to follow the tutorial. I opened the first project for lesson 1, as instructed, but looks like that when he opened it imported bot

    In order to improve my skills and ease with Premiere Pro, I bought Adobe Premiere Pro CC Classroom in a Book and began to follow the tutorial. I opened the first project for lesson 1, as instructed, but looks like that when he opened it imported two media accompanying the project of the lesson and media one of the practical projects that I've done before. Can someone tell me what I did wrong and why it has imported two sets of brackets instead of only in the media for the lesson. Media for two different projects are not storeed in the same place?

    I found the problem. Sorry if I've lost any time. Please do not take into account. Thank you.

  • I get this error every time I open LR, "Lightroom encountered and error during playback of sound preview cache and need to stop smoking" and the application does not open. He said LR would try and correct this error the next time I opened it, but the erro

    I get this error every time I open LR, "Lightroom encountered and error during playback of sound preview cache and need to stop smoking" and the application does not open. He said LR would try and correct this error the next time I opened it, but the error remains. I tried uninstalled and installed the application and the error remains. I use Windows 8.

    Manually delete the cache of the preview of your user folder.

    Mylenium

  • moved object and type next to the bottom of preview page do not

    moved object and the type next to the wallpaper preview page cannot see how to change this sitting?

    With no text selected, press w.

  • Failing to read about ADE software able to read when they have framed color graphics and text files EPDF, how do fix us?

    We have 2 different InDesign files read does not correctly in the drive of the ADE. The two files have framed color images and texts in them. The original file EPDF one showed blank pages for the entire page with text boxes inside when open in ADE (they are wrapped in DRM). Pages that do not have the sidebar appeared fine. Our ebook distributor said us we need to rasterize the file. We are working in InDesign with Adobe Acrobat X Pro 6. We made each page JPEG files and re-imported in an InDesign file and exported in PDF format and our player ADE then showed pages from the sidebar. The file is quite large but and I have a book that has the same problem. What is the problem with our boxes and what are the best solutions as JPEG files for each page? Thank you.

    Try the forum of ADE.

  • How to get and access on all the layers property

    Hello world.

    Try to get and to access a property at the level of the layers all at the same time.

    I wrote a code, but stuck on getting property and its application to another layer.

    Here's the pice of code:

        var myComp = app.project.activeItem,
        propLength = myComp.selectedLayers[0].selectedProperties.length,
        effectName = [];
    
     for (i = 0; i < propLength; i++){
    
          var propName = myComp.selectedLayers[0].selectedProperties[i];    
          var effectPath =  '("'+propName.name+'")';
          effectName[i] = effectPath;
    
       }
    // then adding "app.project.activeItem"+'.layer("'+ myLayer.name+'")'+".effect"+effectName.toString()"
    

    This construction works only when the property is not grouped in "Content" or something else.

    For example:

    app.project.item(6).layer("4").effect("Unsharp Mask")("Amount")          // works fine
    

    But if I would get "1 shot of" property of the shape layer 'Opacity', I had received:

    app.project.activeItem.layer("Shape Layer 1").effect("Opacity")  // false, won`t work for other layers
    

    Instead of:

    app.project.item(6).layer("Shape Layer 1").("Contents")("Shape 1")("Contents")("Stroke 1")("Opacity")     // true
    

    I've also heard of .propertyDepth, but it didn't help me much.

    I would like to automate everything, so please Don't advice me to get the property with the rd_GimmePropPath script.

    Thank you in advance!

    I realize my first answer was light years away from your question. I'm sorry.

    The following function returns the path of a property relative to its layer:

    int getPath (prop, byWhat)

    {

    byWhat must be a string and a 'name', 'remove', 'propertyIndex.

    Returns the path of the pillar (a property) compared to its layer, starting with '.property.

    function sandwich (x) {return (typeof x == 'string')?} "(\"" +x  + "\")" : "("+x+")";}

    If (typeof byWhat == "undefined") byWhat = "name";

    var s = "";

    {s = '.property' + sandwich (prop [byWhat]) + s; prop = prop.parentProperty ;}} While (prop.propertyDepth > 0);

    return s;

    }

    You can test that it works for example like this:

    function test (byWhat)

    {

    model var = layer, prop, app.project.item (1), propPath;

    If (!) () model of instanceof CompItem)) {alert ("item (1) should be a composition.")} Select a property in this comp"); Return ;}

    If (comp.selectedLayers.length<1)>

    layer = comp.selectedLayers [0];

    If (layer.selectedProperties.length<1)>

    prop = layer.selectedProperties [0];

    propPath = 'app.project.item(1).layer(\""+layer.name+"\")"+getPath(prop,byWhat);

    Try

    {

    var p = eval (propPath);

    If (Object.isValid (p)) alert ("selected Prop:" + prop.name + "\r\rproperty path:" + propPath + "rated road \r\rprop:" + p.name + "\r\rsame Accessories?:" + (p is prop) m:System.NET.SocketAddress.ToString ());

    }

    catch (e) {alert 'something was wrong there... »} ;

    return;

    }

    test ("Name");

    test ("remove");

    test ("propertyIndex");

  • Backup hard drives internal and external to separate the partitions on an external drive of a second... ?

    I want to back up an internal hard drive (let's call it 'A') and (B) external drive using Time Machine. Both are 1 TB in size, so I bought a 2 TB external drive and created two partitions (C and D) on this subject, only to receive each backup. So:

    A = internal hard drive

    B = external drive (for "overflow" files)

    C = partition to external drive for backups of A

    D = partition to external drive for backups of B

    My question is, can I set up Time Machine so that A back up C, every time the 2 TB drive is connected, and B backup up to D whenever the two external drives are connected? I thought it would be possible, but at the opening of the Time Machine preferences and selecting D for the first time I get a message saying:

    "You want to stop backup up to 'C' and use"D"instead or back up at the same time?

    If you use the two, Time Machine will take turns backup up to "C" and "D". »

    I wonder if it would just be easier to return to a single partition on the hard disk of 2 TB and have the time machine to perform a backup of everything, that is, both A and B?

    Last question: I'm doing this to improve Yosemite to El Capitan. the operating system affect what I'm trying to get time Machine to do?

    Thank you!

    Use Time Machine to back up or restore your Mac - Apple Support

    I have a non-partitioned device TM backup of your data and your OS disk at once

    If in case you partition and drive "B" needs more than what is on the partition and drive 'A' don't you avoid warning.

    update of the OS is fine, as it will give an output back to a previous TM operating system where you need it, but it is compatible across versions.

  • Try to get a collection of frames of texts related with the second table in my document

    Hi all

    There are two long tables in my document, and I want to do is to get the collection of blocks of text that contain the second table to resize (single height),

    and set the number of columns to 3 columns and column gutter to 0, but I am unable to get the collection of blocks of text that contains the second table.

    I also want to apply a different master page to the pages that contain the second table.

    I know that I can change my number of columns and the gutter using script below, but the thing is I don't want the script to assign my first table,

    and I can not also put the tables in separate the file because there are cross-references.

    Script to change the gutter and the number of columns

    app.findObjectPreferences.textColumnCount = 1;

    app.changeObjectPreferences.textColumnCount = 3;

    App.Documents.Item (0) .changeObject ();

    app.findObjectPreferences.textColumnGutter! = 0 ;

    app.changeObjectPreferences.textColumnGutter = 0;

    App.Documents.Item (0) .changeObject ();

    I'm new to javascript and I searched for solutions for several days, but still can not find how to get it work.

    Any input will be appreciated!

    V

    I think that's what you want.

    var doc, secondTable, secondTableTextCotainers = [], ps, firstFrame, lastFrame, nextFrame;
    doc = app.properties.activeDocument;
    if (!doc) {
        alert("Jerk");
        exit();
    };
    app.findTextPreferences = null;
    app.findTextPreferences.findWhat = "\x16";
    var tables = doc.findText(false);
    if (tables.length > 1) secondTable = tables[1];
    else exit();
    lastFrame = secondTable.parent.insertionPoints[secondTable.index + 1].parentTextFrames[0];
    firstFrame = secondTable.parentTextFrames[0];
    secondTableTextCotainers.push(firstFrame);
    if (lastFrame != firstFrame) {
        nextFrame = firstFrame;
        while (nextFrame = nextFrame.nextTextFrame) {
            secondTableTextCotainers.push(nextFrame);
            if (nextFrame == lastFrame) break;
        }
    }
    var l = secondTableTextCotainers.length;
    // You might want to change this line
    while (l--) secondTableTextCotainers[l].fillColor = "Yellow";
    
  • How to convert specific images on my Clipboard to text once paste the picture on my .pdf document?

    Hey Adobe experts, I could really use your help.

    I have some screenshots of school I pasted on OneNote. These screenshots have a large amount of text that I could use. I created a large .pDF document where I saved my notes and text. Now - how to convert the SPECIFIC images that I stick to the text document? I use the word 'Specific' here because I know I can run OCR on a blank page without any text. But how to do OCR on an image

    It automatically happened a couple of times when I tried to save the document immediately after I pasted the image - when I was under "Edit PDF" I was able to edit and change the fonts of the text. But how can I do this at will? Is there a special button somewhere?

    P.S. I already tried to OCR - but it's only limited to pages without already "renderable text".

    I use Adobe Acrobat Pro DC; 8.1 Windows machine

    Hi SinNombre,

    If you are referring to perform OCR on a page with the image and the renderable text, it is not supported. However, you can use the following workaround for the same thing:

    1. print the PDF document to Microsoft XPS Document Writer or accessing the file-> export to...-> Image-> (an example of TIFF or PNG format)

    2 convert the output created in PDF format. This PDF file contains all the texts and images in the form of images.

    3. run the OCR on this PDF.

    This should solve your problem

  • I use Windows 8.1 and don't see the taskbar when I open Firefox

    I need to clear my cache navigation and can't find the taskbar to start the process.

    Hi Butzi,

    You have a keyboard? Pressing ALT should raise the bar of menus.

  • InDesign crash when the CC2015 try to open documents from older versions

    Someone know why indesign crash when I try to open documents from older versions.

    I just updated to 2015 for CC.

    How to solve this problem?

    I had to reinstall the old version and then it worked.

Maybe you are looking for

  • Charger stopped working

    My phone charger stopped working. I am able to load the phone with another charger. After the appearance, it doesn't look like that it burned or something has happened. I don't know, all of a sudden it stopped working. I can't fixed it from the servi

  • Analog interface for PXI 7811

    I need to read a signal to the PXI FPGA module 7811 ADC PXI 6220 are the frequency of the mismatches FPGA and data acquisition Thank you Concerning Pradeep

  • Packed library in exe

    I'm building an executable that takes advantage of its controls from a packed library.  It works very well in the development environment, but when I create the executable file and distribute it to our network, it is more controls in the packed libra

  • How do you take "screenshots" of my system?

    I'm asked by a potential employer to take a 'screenshot' of my 'system '. How to make a screenshot of that?

  • have any problem print my document on get message ambiguous name detected; tmpdde

    When tring to print a document on my sign documents said ambiguous name detected; tmpdde so I know this isn't my printer have no problem with the other print jobs?