Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

CS4 Library Global Changes

Return to Member Forum

  • Author
    Posts
    • #54328
      Rocky
      Member

      Have a CS4 Library file which contains more than 2000 text-only items all of which are formatted using Times Bold (Postscript). Is there some script or automator method of globally changing the font to Times LT Std Bold?

    • #54336
      rhadin
      Member

      I was going to suggest using the formatting area of the Find but that searches for a style. I, too, am interested in the answer to this question.

    • #54340
      Mike Rankin
      Keymaster

      Rocky-

      Sorry I don't have a good solution, just an observation, that if these items existed as Snippets (which are really just text files) you could do a batch Find/Replace on the AppliedFont value to fix them all. But then you'd have to keep track of 2000 snippets, which could be crazy.

      In this case, the Library is really a tease because all the items are stored within it as Snippets, but AFAIK, they're wrapped in compiled code that will break if you try to edit it. At least, it breaks if I try to edit it.Frown

    • #54347

      Rocky,

      basically I see a possibility doing this by JavaScript (ExtendScript).
      Warning! The following lines of code are a case study for doing so.

      To test this we need some prerequisites:

      1. A blank InDesign CS4 file, make sure it is the only one opened
      2. A new paragraph style with your desired font and font weight
      3. An open library, make sure all assets are single text frames

      What does the script do?

      It will loop through all the assets of the library:

      1. Places the asset (which is one single text frame) to the open InDesign file
      2. Reformats all paragraphs in the text frame's story to the new paragraph style
      3. Removes the old asset from the library
      4. Stores the new asset to the library
      5. Removes the placed text frame from the InDesign file

      For testing the script be aware that:

      1. “Your_Test_Library_Name” in line 11 should be replaced by the name of your test-library
      DO NOT DO THE TEST ON YOUR ORIGINAL LIBRARY!

      2. “Your_New_Paragraph_Style” in line 22 should be replaced by the name of your new paragraph style

      Again: be aware, this script is only a case study. To make it properly work, we have to discuss a lot:

      1. Are all assets in your library are of the type “text”?

      2. Are there paragraph or character styles applied to the text?

      3. Is there formatting without styles?

      4. Is there more than one text frame per asset?

      etc. etc.

      Here is the script. Copy it to your text editor, make sure it is text only, rename the file with the suffix “.jsx” and place it to your InDesign CS4 scripts folder at “Adobe InDesign CS4/Scripts/Scripts Panel”:

      //Uwe Laubender
      //ReformatTextAssets.jsx
      /**
      * @@@BUILDINFO@@@ ReformatTextAssets.jsx !Version! Wed Dec 30 2009 17:17:53 GMT+0100
      */
      //DESCRIPTION:Reformats text assets of library to new paragraph style regardless of local formatting!
      var d=app.activeDocument;

      if(d.pageItems.length==0){
      //Don't forget to enter the suffix “.indl” to the name of your test-library:
      var myLibrary=app.libraries.itemByName(“Your_Test_Library_Name.indl”);

      for(n=0;n<myLibrary.assets.length;n++){
      var assetName=myLibrary.assets.item(n).name;
      var assetDescription=myLibrary.assets.item(n).description;
      var assetLabel=myLibrary.assets.item(n).label;
      var assetAssetType=myLibrary.assets.item(n).assetType;
      myLibrary.assets.item(n).placeAsset(d);

      //Now reformat all paragraphs to the new paragraph style:
      for(m=0;m<d.stories.item(0).paragraphs.length;m++){
      d.textFrames.item(0).paragraphs[m].appliedParagraphStyle=”Your_New_Paragraph_Style”;
      };

      myLibrary.assets[n].remove();
      myLibrary.store(app.activeDocument.textFrames.item(0));

      myLibrary.assets[0].name=assetName;
      myLibrary.assets[0].description=assetDescription;
      myLibrary.assets[0].label=assetLabel;
      myLibrary.assets[0].assetType=assetAssetType;

      d.textFrames.item(0).remove();
      };
      };

    • #54349
      Rocky
      Member

      Uwe,

      Thank you for this solution.

      In answer to your questions:

      1. Are all assets in your library are of the type “text”? YES

      2. Are there paragraph or character styles applied to the text? YES, more than one paragraph style is applied but each one use Times Bold (postscript font), the only font used in everyone of the library assets

      3. Is there formatting without styles? NO

      4. Is there more than one text frame per asset? NO

    • #54359
      Rocky
      Member

      Uwe,

      Did some tinkering of my own on your script. After answering your questions I realized there might be a problem with more than one paragraph style in the individual assets. Based on that, I thought maybe changing your line 22 to this would work:

      d.textFrames.item(0).paragraphs[m].appliedFont = app.fonts.item(“Times LT Std”);

      I am not really interested in preserving existing paragraph styles, or creating new ones for that matter, this is an old library that has been mangled for years but wanted to migrate the fonts to OpenType.

      After making the change (and of course inserting my library name into line 11: BINGO IT WORKED PERFECTLY!

      Excellent!!! Did not have to even indicate fontStyle = “Bold”; in the code and all converted well.

      Thank you again! Happy New Year!

    • #54363

      Happy New Year, Rocky!
      Good to hear that all went well. In the meantime I wrote an advanced version of the script with a little UI, that let you choose an available library and a font. Of course, now it's too late for that, but if you feel like it, test it on your material.

      Just open a library, this time have no InDesign document open, the script will add one by itself and give it a go:

      //Uwe Laubender
      //ReformatTextAssets_2-3.jsx
      /**
      * @@@BUILDINFO@@@ ReformatTextAssets_2-3.jsx !Version! Mon Jan 04 2010 10:58:57 GMT+0100
      */

      //DESCRIPTION:Reformats text assets of library to new paragraph style regardless of local formatting!

      app.documents.add();
      var d=app.activeDocument;
      var pStyles=d.paragraphStyles;

      var fontsList = app.fonts.everyItem().name;

      if(app.libraries.length!=0){
      var librariesList=app.libraries.everyItem().name;
      }
      else{
      alert(“There is no library open. Please open a library and try again.”);
      exit();
      };

      //Begin dialog:
      var myDialog=app.dialogs.add({name:”List of Libraries and Fonts:”, canCancel:true});

      with(myDialog){

      with(dialogColumns.add()) {

      with (dialogRows.add()) {
      with(dialogColumns.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:”Library: “});
      };
      with(dialogColumns.add()){
      var libraryDropDown = dropdowns.add({stringList: librariesList, selectedIndex:0});
      };
      };
      };
      with (dialogRows.add()) {
      with(dialogColumns.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:”Font: “});
      };
      with(dialogColumns.add()){
      var fontsDropDown = dropdowns.add({stringList: fontsList, selectedIndex:0});
      };
      };
      };
      };
      };
      var result=myDialog.show();

      if(result == true){
      var newFont = fontsList[fontsDropDown.selectedIndex];
      var libraryName = app.libraries.item(librariesList[libraryDropDown.selectedIndex]);

      myDialog.destroy();
      };

      else{
      myDialog.destroy();
      };

      if(d.textFrames.length!=0){
      for (n=0;n<d.textFrames.length;n++){
      d.textFrames[n].remove();
      };
      };

      //Getting rid of all paragraph styles that can be removed:
      if(pStyles.length>2){
      for(n=pStyles.length-1;n>1;n–){
      pStyles[n].remove();
      };
      };

      for(n=0;n<libraryName.assets.length;n++){
      var assetName=libraryName.assets.item(n).name;
      var assetDescription=libraryName.assets.item(n).description;
      var assetLabel=libraryName.assets.item(n).label;
      var assetAssetType=libraryName.assets.item(n).assetType;

      libraryName.assets.item(n).placeAsset(d);

      //Now give the old paragraph style a new font:
      for(m=0;m<d.stories.item(0).paragraphs.length;m++){
      if(d.textFrames.item(0).paragraphs.item(m).appliedParagraphStyle.isValid==true){
      var appliedPStyle=d.textFrames.item(0).paragraphs.item(m).appliedParagraphStyle;
      appliedPStyle.appliedFont=newFont;
      };
      else{
      d.textFrames.item(0).paragraphs.item(m).appliedFont=newFont;
      };
      };

      libraryName.assets[n].remove();
      libraryName.store(app.activeDocument.textFrames.item(0));

      libraryName.assets[0].name=assetName;
      libraryName.assets[0].description=assetDescription;
      libraryName.assets[0].label=assetLabel;
      libraryName.assets[0].assetType=assetAssetType;

      d.textFrames.item(0).remove();

      if(pStyles.length>2){
      for(p=pStyles.length-1;p>1;p–){
      pStyles[p].remove();
      };
      };
      };

    • #54366
      Rocky
      Member

      Uwe,

      Will give it a try.

      One thing I noticed as I cycled through my library using my variation of your first script is that the library got very “fat” meaning its size increased alot!

      Is there a way to take the “air” out of a library, sort of like compressing a database?

      Just wondering, can't find anything on the web about compressing ID libraries.

    • #54367

      Rocky,

      hm. Can't tell if reformatting added overhead to your library.
      You said that the library is very old. Does it mean InDesign CS2? Maybe CS2-libraries were encoded in a more compressed way…
      Pure speculation.

      Something different came to my mind. I hope you noticed that after running the script you no longer had the tiny previews along with the assets. That is because InDesign is not able to recompose the placed text frames when running.

      To generate the preview just add the following line:

      d.textFrames.item(0).recompose();

      before that line:

      libraryName.store(app.activeDocument.textFrames.item(0));

      And when you are at it just swap “app.activeDocument” to simply “d” in that same line; in this case it's all the same, just it's short form:

      libraryName.store(d.textFrames.item(0));

Viewing 8 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads