Skip to main content
Participating Frequently
June 1, 2011
Answered

Cleaning up script

  • June 1, 2011
  • 1 reply
  • 2675 views

Hello All

We often translate indesign files using a CAT tool to open the idml file. But most of the InDesign files we are sent have been created by people who take a great many short cuts to get things to fit, which maybe good for them but not for us.

We need a script that can set all kerning to 0 or a constant value throughout a document, remove all stretched text and change any thing with ALL CAPS to true uppercase.

There are a few more niggly things we have to do to clean it up which can take a few hours for a large document so it would be good it there was a script that could do this or if anyone knows how to create one for us we would be happy to work with you to create it.

This topic has been closed for replies.
Correct answer Kasyan Servetsky

Here is a new version:

const kerningConstant = 0;
var doc = app.activeDocument,
stories = doc.stories,
story, text, s, t;

for (var s = 0; s < stories.length; s++) {
     story = stories;
     for (var t = 0; t < story.texts.length; t++) {
          text = story.texts;
          text.kerningValue = kerningConstant;
          text.verticalScale = 100;
          text.horizontalScale = 100;
          ChangeCase(text);
     }
}

function ChangeCase(text) {
     var i, found;
     if (text.contents != "") {
          app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
          app.findGrepPreferences.findWhat = ".+";
          app.findGrepPreferences.capitalization = Capitalization.ALL_CAPS;
          var found = text.findGrep();
          if (found.length > 1) {
               for (i = 0; i < found.length; i++) {
                    // $.writeln( i + " - " + found.constructor.name + "/"+ found.contents );
                    found.changecase(ChangecaseMode.UPPERCASE);
               }
               app.changeGrepPreferences.capitalization = Capitalization.NORMAL;
               text.changeGrep();
          }     
     }
}

1 reply

Kasyan Servetsky
Brainiac
June 2, 2011

Here is a simple script to get you started:

const kerningConstant = 0;
var doc = app.activeDocument,
stories = doc.stories,
story, text, s, t;

for (var s = 0; s < stories.length; s++) {
     story = stories;
     for (var t = 0; t < story.texts.length; t++) {
          text = story.texts;
          text.kerningValue = kerningConstant;
          text.verticalScale = 100;
          text.horizontalScale = 100;
     }
}

It's not clear to me what you do with ALL CAPS in InDesign — do you turn them off and retype the text manually with Caps Lock on?

Regards,

Kas

Participating Frequently
June 2, 2011

Hi Kas

Thanks for that, I shall try it out.

When we come across text that is using the 'ALL CAPS' control we select the text and turn this off, then use a shortcut to convert to uppercase, using the type/change case/uppercase command.

The problem is when we upload to our CAT tool everytime there is a change to the formating in a word then 'tags' are inserted where a change begins and ends, so if a designer has been mucking about with kerning, tracking, scaling text etc or has been using "ALL CAPS" on some letters and not on others (yes we can have half a word in All CAPS and half in true uppercase!) then text can look like this to the translator.

T*h**is i**s v*e**ry d*i*ffi**cu*lt to* re*ad *text*

As we typeset the text after translation in InDesign we add our own tweaks where necessary.

Participating Frequently
June 3, 2011

Hi Kas

That worked perfectly....

Many thanks for your help, I shall be incontact outside of this forum if we need your expertise again.


Hi Kas

Just realised the text which was all caps was unaffected by the commands to set kerning to 0, was this because of the order the script is carried out in?