Script to delete alternate layout

I am writing a script that puts ID documents into the correct folder and naming structure to be batch imported into a folio. The documents have two alternate layouts, the original "Print" layout and an "I" layout for ipad. I want the script to delete the "Print" layout pages before processing the document. This is effectively the first section of the document. If I try to target it as below, I receive an error that says cannot delete the doc's default section.
var allSections = myDoc.sections;
   var numSections = allSections.length;
   if (numSections > 1){
       allSections[0].remove();
How do I correctly target this section, and what is the correct syntax for targeting it by it's altenate layout name, "Print"
Many thanks,
Tim

@Tim – For a general solution removing ALL PAGES of an alternate layout, we need a more elaborate scripting solution.
I was wrong with my statement in  post #7 that we have only to test for the value of "alternateLayout" to get all sections that belong to a specific alternate layout.
The value of a specific "alternateLayout" in a document is unique.
If more than one section is applied to one alternate layout the value of "alternateLayout" is an empty string.
So, basically, what I suggest is:
1. You have to loop through all sections and test for the value of "alternateLayout".
2. If the name of the alternate layout you want to remove is found store the "pageStart.documentOffset" value (( EDIT removed /EDIT )) in a variable for further use after the loop. Let's call that variable "firstPageIndex".
Store the length of the section to a variable we can call "lastPageIndex", add the value of "firstPageIndex" immediately (we cannot assume, that our found alternate layout will always start on page indexed zero).
Also use a boolean control. Let's call it "targetHit". Since our alternate layout is found now, we will set it to the value "true".
3. When the loop hits the next section and the value of "alternateLayout" is an empty string, you know, that this section also belongs to the found alternate layout. Otherwise the value would not be empty, but a name of a different alternate layout we do not want to remove the pages from.
You know that exactly, because you ALSO check the value of our control
"targetHit". (Remember, in our example its value is "true" now).
4. So, if both conditions are met at the same time, add the sum of "pageStart.documentOffset" and "section length" of the current section to the variable "lastPageIndex".
5. In case the value of "alternateLayout" is not an empty string AND not the name of our target AND the control value is "true", we have met another alternate layout and we have to break the loop immediately.
After the loop we could use our two variables "firstPageIndex" and "lastPageIndex" to remove all pages that are aggregated under the alternate layout name of our target:
myDocument.pages.itemByRange( firstPageIndex, lastPageIndex-1 ).remove();
Uwe
Message was edited by: Laubender
Message was edited by: Laubender

Similar Messages

  • Alternate Layouts and app.exportMiniFolio

    Ok I have the script working and creating my folio BUT.. the function calls for two documents
    if I try and pass in a document with alternate layouts I get a message saying that documents containing multiple page sizes are not allowed.  if I copy the document and delete a layout off of both the folio builds fine...
    Any suggestions on how to do this using the single INDD file?  seems to defeat the purpose of having the alternate layouts if the functions cant support them, or I am missing something here?
    CMY

    Ok I have the script working and creating my folio BUT.. the function calls for two documents
    if I try and pass in a document with alternate layouts I get a message saying that documents containing multiple page sizes are not allowed.  if I copy the document and delete a layout off of both the folio builds fine...
    Any suggestions on how to do this using the single INDD file?  seems to defeat the purpose of having the alternate layouts if the functions cant support them, or I am missing something here?
    CMY

  • How can I export a pdf of an InDesign alternate layout from a book?

    Hello:
    I have a book that is in a 6×9″ layout and I would like to make an alternate layout for 8.5×11 (and other formats) then export both as independent books to PDFs. How can I do this or is there another better way? I thought alternate layout would be the way to go, but I don’t think I can export the alternate layouts for all my chapters/etc., from the book menu without including ALL the pages from each layout?
    Thanks for any direction or advice!
    Kevin

    Hi Willi:
    Thanks for your prompt response.  Do you know if there are any scripts that can do this or at least help automate some of this process?
    Thanks!
    Kevin

  • Alternate layout created when moving pages from one  document to another

    I'm using CC on Windows 7 -  I have 2 documents  that I want  to merge and make into 1 [I know people will want to know why I would want to do this -  each document is  the result of a different data merge - data merge can only handle one master page - so I have  2  datamerges - 2 files - and just need to  merge the 2 files]
    This used to work beautifully in  ID 5.5 - now when I   use the pages panel to move the pages to  the other document - it creates an alternate layout - it is then very difficult for me to  interlace alternating  pages - - I use dot be able to just move the pages into place - but with eh 2 layouts it is behaving differently and in a way I do not understand. Is there any way I can get around this? or avoid the alternate layout and just have one. The 2 page sizes are identical so it is not a problem of  varying size - the paragraph styles are all the same as well. I have tried to delete the alternating style but it  will delete all the pages as well.
    Thanks

    Maybe its time for me to Replace my Preferences, because I also have 8.0.2, and I tried the same thing with two new documents based on the same preset - it still made an alternate layout. When the moved page is placed in the middle of several pages (say - after page 2, of 6 pages) all the pages after the inserted one become part of the new alternate layout. In this example, I had a six-page document, and moved one page of the other identical document to After Page 3 Here's the result

  • Alternate Layout Bug report-

    I just opened an ID file with alternate layouts in ID CC. All the pages were there but, they were not layed out in the pages panel as alternate layouts; there was just one long list.
    I selected a page and chose, "Create Alternate Layout", and the alternate columns in the Pages panel appeared. Command-Z deleted the last layout group just created.
    Just thought you would like to know.
    BTW, I wish it were possible to swap one page of an alternate layout with the first page of that alternate layout; unfortunately, that does not seem possible. It seems the first page must always remain the first page. This is my wish for the next update.

    Did you try opeing the Pages panel flyout menu and choosing View Pages > By alternate Layout?

  • Indesign cc. Alternate layout. Master B.

    Background.
    New > Document > web.
    I am creating an .epub.
    QUESTION.
    Does it matter if the layout is vertical or horizontal in Indesign CC ?
    I followed Anne Marie Concepcion's tutorial for creating an Alternate Layout.
    http://tv.adobe.com/watch/visual-design-cs6/working-with-alternate-layouts/
    It is actually for Indesign CS6.
    I Created an alternate layout so now I have two:
    Letter V  which looks like landscape.
    800x600 which looks like portrait.
    I thought that I would keep only the 800x600 portrait.
    The tutorial shows how you can 'delete' the layout you do not want and then do a 'save as'.
    I did this.
    But now I  No Longer Have a Master A.
    I only have a Master  B.
    QUESTIONS
    How can I change this to be called Master A.  ?
    With Indesign CC, and with the updated functionality of tablets, does it really matter which layout I use ??
    I created an ePub in 2010 using Indesign CS5, and I did not use alternate layouts and the ebook seems to be fine on all tablets.
    Can someone please clarify these things for me.
    Thanks.

    Thanks Anne-Marie.
    So I think that I should just delete my 800x600 Layout ?
    The 800x600 layout physically looks in my pages panel  to be vertical.
    And then save it again ?
    QUESTION: Which Layout should I keep ??
    That will leave me with the Letter V layout which was what is listed in all of my saved versions.
    This is where I suppose I became confused.
    The fact that that the term LETTER V is used  when I created a document for the WEB.
    'LETTER'   denotes physical pages to me.
    V is for vertical.
    document > new > web      defaults to 'horizontal' orientation if I am not mistaken
    Does that makes sense ?  My confusion.
    It is just feedback.
    I just hope that I do not have to go back and re-edit those last 50 pages
    Thanks for the help. 
    I love adobe products.
    I just want to understand this and move onto the next step.
    I have been dreaming of a strategy to get my TOC to work the way I want it too.
    Thanks Bob too.

  • Looking for help with PowerShell script to delete folders in a Document Library

    I'd like to create a PowerShell script to delete old folders in a Document library that are over 30 days old. Has anyone created something like this?
    Orange County District Attorney

    Hello Sid:
    I am trying to do the same and Iam running the script to delete the subfolders inside a folder  but I have some errors. 
    Could you please take a look?
    _______Script________
    $web = Get-SPWeb -Identity https://myportal.mydomain.com
    $list = $web.GetList("ar_mailingactivity")
    $query =  New-Object Microsoft.SharePoint.SPQuery 
    $camlQuery = '<Where><And><Eq><FieldRef Name="ContentType" /><Value Type="Computed">Folder</Value></Eq><Leq><FieldRef Name="Created" /><Value Type="DateTime"><Today OffsetDays="-30" /></Value></Leq></And></Where>'
    $query.Query = $camlQuery
    $items = $list.GetItems($query)
    for ($intIndex = $items.Count - 1; $intIndex -gt -1; $intIndex--)
       $items.Delete($intIndex);
    ________Errors_______
    Unable to index into an object of type System.Management.Automation.PSMethod.
    At C:\Script.ps1:2 char:22
    + $list =$webGetList <<<< "ar_mailingactivity"]
    + CategoryInfo
    :InvalidOperation: (ar_mailingactivity:String) [], RuntimeException
    + FullyQualifiedErrorID
    :CannotIndex
    You cannot call a method on  a null-valued expression.
    At c:\Script.ps1:6 char:24
    + $items = $list.GetItems <<<< ($query)
    + CategoryInfo
    :InvalidOperation: (GetItems:String) [], RuntimeException
    + FullyQualifiedErrorID
    :InvokeMethodOnNull

  • Script to Delete more than 1 user from the database

    Hi All,
    I have a list of users in a file and i want to write a script to delete all these
    users from my database.
    I have tried deleting users using:
    drop user user1,user2,user3..... but it doesn't seem to work.
    Can anyone suggest how do i read the users from the file and delete them one by one

    You can use an external table :
    SYS@db102 SQL> select username from all_users
      2  where username like 'USER%';
    USERNAME
    USER1
    USER2
    USER3
    SYS@db102 SQL> !cat users_to_drop.txt
    USER1
    USER2
    USER3
    SYS@db102 SQL> create table test.users_to_drop
      2  (
      3     userx   char(30)
      4  )
      5    organization external
      6  ( type oracle_loader
      7    default directory work
      8    access parameters
      9     ( records delimited by newline
    10     )
    11     location ('users_to_drop.txt')
    12  )
    SYS@db102 SQL> /
    Table created.
    SYS@db102 SQL> begin
      2     for U in (select userx from test.users_to_drop) loop
      3             dbms_output.put_line('Dropping '||U.userx);
      4             execute immediate 'drop user '||U.userx||' cascade';
      5     end loop;
      6  end;
    SYS@db102 SQL> /
    Dropping USER1
    Dropping USER2
    Dropping USER3
    PL/SQL procedure successfully completed.
    SYS@db102 SQL> select username from all_users
      2  where username like 'USER%';
    no rows selected
    SYS@db102 SQL>

  • HOw do I change my rescue email address?  I want to change my Apple ID and it's telling me that it can't be the same as my rescue email , even though I have already deleted "alternate email address"

    HOw do I change my rescue email address?  I want to change my Apple ID and it's telling me that it can't be the same as my rescue email , even though I have already deleted "alternate email address"

    See Kappy's previous write-up.
    Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities

  • When I move pages from one document to another, it creates a new alternate layout.

    Hello,
    I'm having an issue with combining some documents. Usually I use the "move pages" command and tell the pages to integrate with another document. However, because of the new alternate layout feature, both documents have the default layouts as "Letter V". So when I move pages from one document to the end of another, it creates a new alternate layout labeled "Letter V2" and "Letter V3" etc. Is there a way to make the pages just go into the main layout of Letter V without creating a new alternate layout? How do I merge alternate layouts created in the integrated document? All documents are the same page size and orientation.
    Thank you kindly,
    Sheena

    Petrill,
    Thank you. I was trying to do that yesterday, but it was grayed out. It seemed to work alright today.
    Thanks,
    Sheena

  • Publishing an alternate layout in InDesign CS6

    I've create a 3 page sample file to show a client how they can re-purpose their InDesign print file and use InDesign to create alternate layouts. I've created a test file that has 2 alternate layouts. One is the standard iPad portrait view and the other is an iPad landscape view. I simply want to output this file as a PDF that I can show to the client on an iPad. How do I output or publish this file so that when view on an iPad it will show the landscape layout in landscape orientation and the portrait layout in portrait orientation?

    Small correction: You CAN create EPUB3 fixed layout if you have CS6, but it can be a painful process. Anne-Marie Concepcion explains how in her video on Lynda.com:
    http://www.lynda.com/Dreamweaver-tutorials/Comparing-looks-fixed-vs-flowable-EPUBs/94249/9 9018-4.html

  • Adding pages to articles which contain alternate layouts

    If I have an article with alternate layouts set up and decide I need to add another page it does not seem to play nicely.
    In the pages palette  I have 2 columns iPad H and iPad V. If I create a new page under iPad H and try to give it an alternate layout I get a dialog saying "Alternate layout name cannot be blank, must be unique, and cannot end with a "*" or a ";" character." It will not let me save as iPad V as there is already a layout there so I save as iPad V2 but when I test on iPad the H page shows up in the layout but the V2 page does not.
    Does this mean I need to create new article to replace the old one, add all my H layouts to it and then create alternate layouts for each of these again?
    Cannot find a good tutorial on the subject.
    Message was edited by: RollDotHome

    Doesn't seem to work – something as simple as this! Screenshots show new page moved to end of doc and also what happens when I put after page 1.
    Also attached are pages prefs. Pages and spreads allowed to shuffle. Is this correct? Pages just dance around rather than staying put!
    Help very much appreciated, I'm probably missing something very obvious!

  • Export an alternate layout from a indesign book

    Hello,
    I'm working on a big file, which has been, for size reasons, separated in multiple files that have then been assembled in an indesign book
    Problem: This document is edited for print and also as an interactive pdf for ipad, which is why I have created an alternate layout for the ipad version, which contains a navigation based on hyperlinks, linking different pages and documents from the Book.
    But here is the thing, when exporting the whole book to pdf (using the Indesign Book panel), I can't choose the layout I want to export, as I can do when I export from a single document with several alternate layouts
    What I get when I export from a single file with two alternate layouts to interactive pdf
    What I get when I export the Indesign Book with two alternate layouts to an interative pdf
    Why is that? Is there a way I can export only one layout without having to RE-assemble the whole document into one file?
    If I export the whole book as it is, my two alternate layouts are just following each other and it's a big mess, not to mention the hyperlinks don't work anymore.
    Also, if the only way is to make one file, the file is then too heavy to be worked with, it's 280 pages long, with HD images on every page ( and the alternate layouts double the pages...)
    Does anyone have a solution?

    You mean, breaking the document into two or three files and then exporting each of these and then assembling the pdf files?
    But then the hyperlinks from one doc to another don't work. I tried it already.
    The problem is that I need to export ALL of these documents into ONE pdf because of the interactivity of the hyperlinks.

  • Need a script to delete files

    Hi
    Can someone advise me on how to create a script to delete certain files from a users home account at logout?
    The files that I want deleting are .plist files in there ~/lib.../preferences folder, this is so I can ensure that all users will have the same settings for certain files next time they login again.
    Thanks

    That being said, if you you still really want to do this you can create a logout hook and write a shell script to remove the files.  See "About Daemons and Services", Appendix B on writing a logout hook.
    But a far easier way is to create Account's login item that will cause a shell script to be launched to delete the files.  You can encapsulate the shell script so it runs as an application that can be added to the Login Items.  One such encapsulator is Platypus.
    Note, rather than delete them, if you want to ensure all the specific plists have specific settings, then create a master set of them and copy the master set into the Preferences directory (being careful to observe ownership and permissions settings of course).

  • Buttons do not appear in alternate layouts

    Hi
    I have a 45 page app.  Each page has button on it that call other pages, play video, or call an MSO
    When I create alternate layouts not all the buttons appear on the new layout
    the buttons that DO appear are:
    1. A button that calls n MSO with two states
    2. A button that calls a video to play
    The buttons that do not appear in the new layout are buttons that call another page in the book.
    I have hundreds of buttons in the app/book.  All the buttons are on their own layer in each document and that layer is at the top of the layer panel.
    How can I make the buttons show up on alternate pages?
    If I have to copy and paste the buttons to the new layouts - is there a method that the copy and paste command actually keeps the link, so I don't have to relink every button on each of the new layouts... that is a big nuisance.
    So.. I guess I have two questions:
    1. How to make the buttons automatically appear on alternate layouts
    2. If they won't appear how can copy and paste have some brains?
    thanks
    Deb

    Since alternate layouts and buttons are core InDesign features, moving this post to the InDesign Forum.
    Neil

Maybe you are looking for