Scripts to insert metadata automatically to document with paragraph style

Hello,
I am trying to find a way to automatically insert  metadata into my document through paragraph style in indesign cs5.5.
This will be myDocument title, the Author name and myDocument description.
Is there anyone who can help me with this project?
Thanks.

Place the script in the following location: C:\Program Files\Adobe\Adobe InDesign CS6\Scripts\startup scripts
If you close the document the script will automatically put the metadata in your indesign file (use ctrl+w or menu -> file -> close option to close the file)
Code:
#targetengine session
//if you want to test the script for your active document, comment the below line else copy the script in your startup folder
app.menuActions.itemByName("Close").eventListeners.add("beforeInvoke", function()
var myDoc = app.activeDocument;
var docTitleText="";
var docDescripText="";
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = '.+';
found = app.activeDocument.findGrep (true);
for (j = found.length-1; j >=0 ; j--)
    var foundText = found[j].contents;
    //You can define multiple Paragraph style for Document Title
    if(found[j].texts[0].appliedParagraphStyle.name=="docTitle1")
        docTitleText=found[j].contents;
    else if(found[j].texts[0].appliedParagraphStyle.name=="docTitle2")
        docTitleText=docTitleText + " " + found[j].contents;
    else if(found[j].texts[0].appliedParagraphStyle.name=="docTitle3")
        docTitleText=docTitleText + " " + found[j].contents;
    //You can define multiple Paragraph style for Document Description
    else if(found[j].texts[0].appliedParagraphStyle.name=="docDescription1")
        docDescripText=found[j].contents;
    else if(found[j].texts[0].appliedParagraphStyle.name=="docDescription2")
        docDescripText=docDescripText + " " + found[j].contents;
    else if(found[j].texts[0].appliedParagraphStyle.name=="docDescription3")
        docDescripText=docDescripText + " " + found[j].contents;
with (myDoc.metadataPreferences){
    author = "My Name";
    documentTitle = docTitleText;
    description = docDescripText;
Vandy

Similar Messages

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • How to export RTF with paragraph style names?

    Anybody can help me "how to export RTF with paragraph style names?"
    Thank you

    It's not something that's natively done with Indesign.
    However it's possible that it might be able to be scripted.
    Check the scripting forum
    http://forums.adobe.com/community/indesign/indesign_scripting

  • Automatically open document with Pages 5

    When I upgraded from Pages 4.3 to 5x, documents were automatically set by the installation to all open with version 5.0.x . Due to some initial problems with Pages 5, I changed the setting so that Pages 4.3 opened all documents. I did that by command-i, get info, open with Pages 4.3, and change all.
    Now I want to default back to opening with pages 5.0.1, but if I do the same procedure (command-i, get info, open with Pages 5, and change all), Pages is still opening documents with version 4.3.

    All Pages files no matter what version and incompatibility have the same extension .pages.
    That makes it impossible to get the System to stick with a choice in Finder.
    Trash/archive whichever one you don't want.
    Peter

  • Formatting Word document with APA style in Pages

    I have been asked to format a word document into APA style; however, I use Pages and do not have Microsoft Word. Can I take the document, format it in Pages and then save it again as a Word document? Will everything transfer correctly? Or am I asking for a major headache?

    Welcome to the forum.
    The search tool of this forum is also for you.
    Searching with the intricate key string _*format AND apa*_
    return this link :
    http://discussions.apple.com/thread.jspa?messageID=11191313
    Yvan KOENIG (VALLAURIS, France) jeudi 15 avril 2010 10:21:30

  • Create automatic white gap/bar with paragraph style

    Hello,
    Thanks to your help and the Paragraph Ruler trick, I managed to get automatic title formatting (the grey background)
    Now, I would like to get automatically white gap as in line two but I can't figure out how to do it (tried with strikethrough but it's all over the text, you can't cheat).
    Any idea?
    Thanks.

    Here I am (sorry I didn't answer before, during the weekend i am not in my office).
    You didn't tell us why do you want to change the text box width? That could help us to give you a better answer.
    However if you need to have different text box width you can use this method:
    Only one paragraph style with only one rule column width, "vertical line" and grep style.
    Below one example:

  • Problem with paragraph style overrides and character formatting

    I've had this problem for a long time, and sometimes it resolves itself, sometimes it doesn't. Finally I'm begging for help.
    I am typesetting academic articles into a journal.  We use endnotes. The endnotes have both italic and regular formatting--italics for book and journal titles, and foreign phrases.
    Sometimes when I place the text, the formatting reverts to whatever it was in Word.  To try to fix that, I've begun stripping the Word formatting from the original document, making everything "Courier New" and just importing it like that.  I figured this would clear a lot of the problems I've had with fiddly formatting issues.
    I was mistaken. 
    Here is what happens:
    When I place the document it comes up in the original Courier New font, with italics and other formatting intact.  If I click "article style" which is the main article paragraph  style format, normally it changes.  but if I right click and select "apply article style" it is more likely to change the paragraph to the proper style, with italics and other formatting still intact.
    But when it gets to endnotes, I'm sort of screwed.
    My endnotes style is a bulletted style, so that I can have the endnote numbers consistent.  but this seems to screw all the style formatting.
    Here is what I do:
    With the cursor in endnote text, I click "bulleted endnote style".  The character format remains the same, with a + beside the style. The endnote number format is different, however.  If I click "clear overrides" it does in fact change to the proper formatting, but it strips any italics or other character in the text.  This is frustrating because many of these endnotes have lots of italicized journal and book titles, and it takes a long time to figure out which ones I need to reitalicize manually.
    I have tried to use the "customize style import>Style mapping" but it has not fixed anything.
    Please help me figure out how to make these transitions more smoothly.  I am open to suggestions both on how to make the changes once the document is placed in the Indesign file, and also making modifications to formats in the native Word file so that I don't have these problems. 
    Thanks
    Dan

    Sorry, that last message wasn't supposed to send (if that's not obvious!). I was writing it and got interrupted.  Damn iphone. 
    I know why there are two numbers.  This is not an issue. What I didn't finish writing was that, the note number before i bullet it is a different font/ format. Again, not a problem.  Here is something interesting, though.  If I delete that original number by placing the cursor in the middle of it (say a between the 4 and 2 of 42) then delete everything by Shift+arrow forward, press delete then delete the rest of the unnecessary characters, THEN apply the style formatting, it works just fine.  Is it something to do with the character codes of those original note numbers? 
    Word drops in so many hidden codes that it screws everything up!

  • Framemaker 8 problem with paragraph styles

    Hi,
    I manage a documentation (one file) including paragraph styles organized like that :
    -- Chapter
         |--- Sub chapter
           |--- Sub Sub chapter
    My question is simple
    When a create a PDF file from my document, including bookmarks, I'm encountering the following problem :
    The "chapter 4", "sub chapter 4" and "sub sub chapter 4" paragraphs are created correctly. The bookmarks are created with the correct place.
    Like that :
    |---- chapter 4
      |---- sub chapter 4
       |----- sub sub chapter 4
    BUT
    The "sub sub chapter "5 paragraph styles are created into the "Chapter 4" structure, added with the "sub sub chapter" of Chapter 4. And the Chapter 5 just contains the "chapter 5" and "sub chapter 5" bookmarks.
    Like that :
    Chapter 4
        |---- sub chapter 4
           |---- sub sub chapter 4
           |---- sub sub chapter 5
    Chapter 5
       |--- sub chapter 5
    After checking the structure of my document, I do not find any thing which could create this problem.
    The paragraph styles seems to be correct.
    Thank you so so much to help me because I don't know how to replace the "sub sub chapter 5" below the" sub chapter 5".
    Phil ;o)

    There are a few ways to go with this. One is to put all the files in a Book,
    temporarily, and set the one with the correct style definition as the
    source, then synchronize the paragraph styles. This will change ALL styles
    with the same names throughout all the documents, and add any styles that
    are present in the source, but not in one of the other files, so it is a bit
    risky, especially if any styles are based on or [Basic
    Paragraph] itself is used in one of the files and it isn't already defined
    exactly the same in all files.
    You can also open any file and go to the Paragraph Styles panel menu and
    choose Load Styles, then select the style you want to load, and how to
    handle a conflict (Use Incoming), which will give you more control over what
    happens.
    Or each time you open a file and get the missing font warning you can go to
    Find Font and select the missing font, then pcik your substitute, check the
    redefine styles box, and click Change All. This would probably be the best
    choice since it doesn't depend on style names to make the correct changes.

  • Having trouble with paragraph styles in CS4?

    Let me start by saying that I am recently switched from Quark, so I am very much a newbie at InDesign. I have been watching as many videos as possible, but can't seem to find the answers in them to specific questions like this.
    I have been taking old brochures that were created in ID3, and pasting type and photos into a new format that was created in ID4. The new format has paragraph styles created already, with updated fonts and other formatting as well.
    When I flow in all the new type, and click on the style sheet, it does change the type to the correct font and size, but there are formats within the paragraph that are not being updated. For instance: the whole paragraph (according to the style applied) should be Gotham Book, but even after applying the style to it, part of it stays Gotham Bold. It was bold in the earlier version of the document, but needs to be unbolded in this one.
    Why, when I apply the style, does it not affect the whole paragraph?

    The latter: InDesign CS3 files are being changed to a new design in InDesign CS4. I did not create either of these files, but am just making the changes from old style to new style, on about 15 different brochures.
    I guess I need to find a quick way to undo any character styles that were applied previously throughout the whole brochure. I want to be able to flow in the old copy, select all of the body copy for instance, and apply the new paragraph styles, without worrying that there is some other formatting in there that I don't even know about. I thought that applying the new paragraph styles would undo ANY of the previous formatting, but that turns out not to be the case.
    I think the poster who suggested doing a find/change might be onto something, but my brain hurts right now, so I am quitting for the day and having a lovely glass of chardonnay... I'll start again fresh in the morning.

  • Locking up with paragraph style change

    I'm using the latest version of InDesign CC 2014; I'm working on a relatively simple 154-page document.
    When I try to apply a change to a paragraph style, however, the application quits responding and I get the "beachball" until I force-quit. I've tried changing the style within the Paragraph Styles dialog, and changing it in the text then redefining the style. Nothing works.
    I also tried exporting the file to be able to be opened in InDesign CS6; that crashed the application, and sent a report to Adobe.
    Any help?

    I've found that it is document-specific; in other words, it only happens with certain ID documents. But I can't tell what the common points are among the documents.

  • Issue with paragraph styles and overflow

    Hi all, I have been having a massive problem with my paragraph styles for a book I am working on for my employer.
    http://cl.ly/2b3p2q412H0b1r3n1L3Z
    The paragraph on the bottom right is the overflow text. For some reason, although the paragraph is all in the "body" paragraph style, once it goes into the overflow textbox, the spacing changes. If I expand the textbox on the left, everything is single spaced. It is quite bizzare.
    I have also tried deleting the textbox on the right and creating a new overflow textbox, but there is no change... I can't figure out what is happening.
    I am using Adobe InDesign CS5.5..
    Thanks!

    (Without looking at the file) Check that paragraph for "Align to baseline" settings.
    See http://www.youtube.com/watch?v=Jla1sy_0FLQ for what this is :)

  • How to automatic encrypt documents with Acrobat 9 standard ?

    Hello,
    I wont to encrypt documents automatically if the document is saved with a standard password.
    Is that possible ?
    I have the feeling it should be possibe with some jave code which is invoked during document close.
    The background for this question is that there is a application running with automatically creates PDF-files using Acrobat standard, and sends the files with smtp-email. I want to enctypt this files and there is no chance to configre the application in this way.
    Thanks,
    Thomas

    I have installed the following Javascript and still have problems to execute the function "this.encryptUsingPoliciy", the error message is "is not a function". It seems that "this" does not identify the currently opend document.
    Using the variable "doc" the code runs errorfree and does what I want, but only on the new opened document.
    I simply want to encrypt every document which is opened and saved with a Security Policy !
    What I'm doing wrong ?
    Thanks,
    Thomas
    /* Applying a Security Policy to a PDF Document */
    /* You need to create a security policy before running this script */
    /* Use "Advanced > Security > Manage Security Policies" menu */
    var ApplySecurity = app.trustedFunction(
    function()
      var oMyPolicy = null;
      var sPolicyName = "StandardPassword";
      app.beginPriv();
      // First, Get the ID of StandardPassword security policy
      var aPols = security.getSecurityPolicies();
      for(var i=0; i<aPols.length; i++)
         if(aPols[i].name == sPolicyName)
              oMyPolicy = aPols[i];
              break;
      if(oMyPolicy != null)
         // Now, Apply the security Policy
         // var doc = app.newDoc();
         // var rtn = doc.encryptUsingPolicy({oPolicy: oMyPolicy});
         var rtn = this.encryptUsingPolicy({oPolicy: oMyPolicy});
          if(rtn.errorCode != 0)
               // Print error message into JavaScript Debugger Console
               console.println("Security Error: " + rtn.errorText);
      app.endPriv();
    ApplySecurity();

  • Inserting photo into word document with new Yosemite OS X

    iPhoto has gone away after downloading the new Yosemite OS X program.  Now it is Photos.  I am attempting to drag or insert a picture into a word document for work.  Unlike the old iPhoto, double clicking on the photo does not allow me to "Copy" so I may then "Paste" on my document.  In addition, when I attempt to drag the picture onto the document where I want it, the picture goes right back to the photo library.  Tried pretty much everything I know and my tech guys from work.  Anyone have this problem or know of the solution?

    My photos are not in/on iCloud. In Microsoft Word 2011 I can use
         Insert > Photo > Picture from File ...
    and then navigate to the my 'Pictures' folder and insert a picture successfully.
    Can't find a direct way of going from Photos to Word. In practice, this is not a big issue for me because in most cases I want to reduce the size of the image, which I do by selecting the image(s) I want in Photos.app, then switch to Preview.app, command-N (New from clipboard). Once in Preview.app I can transfer images to Word by drag and drop from the thumbnails, etc. The neat thing about this workflow is one can select several images in Photos at once and have them all open in Preview with one keystroke.
    C.

  • Problem with special characters being randomly inserted into a text document with Surface Pro

    Why are these special characters appearing in the text below?  How do I correct this issue?
    EXAMPLE:  Alice's friends took advantage of her they got all their nai;ls done.
     Her tabl;et is no l;onger working and does not know what happ;ened to it;.
    School: Her grades are falling and so she stop;ped working the program ;with PCC> She is failing all her cl;asses;. She is taking sociology class and he grades really hard. Science cl;ass she took a test and it bro;ught her down. She will have to do better
    on next test to ;;raise ;grade;.; Math cl;ass she will have to make up; a quiz for math—the math is getting harder—geometry is hard for her. Career cho8ices class—he has not p;ut in any grades yet but there is no grade yet. She re;ports that she is ;stubborn
    and she does not ask for help. She is staying after school; for working on her studies;. Grade ;;;;;;;;check wil;l be out next week.
    Therapy: Last f;4riday the therap;ist s;c;hed7led with Alice's bio dad and the therp;iast did not show and was not sure if dad showed because she does not know what dad l;ooks loiike.; They ar3e schedule;ed for this Friday. morning.;

    Hi,
    DId this issue just happened in this text?
    Please open the other text file to check the result.
    I suggest we create a notepad file,and type some words and save it.Then open it again to see the result.
    Meanwhile,as S.Sengupta mentioned,check your input method and Keyboard layout.
    Regards,
    Kelvin Xu
    TechNet Community Support

  • Automatically create Object, Character & Paragraphs style when you copy & paste the same item.

    InDesign could create styles automatically. If I am copying and paste an object or paragraph - that means I will be using it in multiple pages and consequently be making changes to it. I know I can always create a syle for all my elements, but having that feature build-in would be great. Especially for the designers like me who works on small documents. Great Forum!
    Thanks!

    InDesign make it really easy for you to create styles. I just believe that having it as an automatic feature (of course, an optional feature) would save time when working in small - mini publications, where there is really no need to create syles . Just my thought.

Maybe you are looking for