Reply To: CS4 Library Global Changes

#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();
};
};

This article was last modified on December 30, 2009

Comments (0)

Loading comments...