Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Like an action

Community Beginner ,
Dec 14, 2017 Dec 14, 2017

Hi guys,

I need an "Action like" functionality, and I want to know how to do it.

For DTP purposes, I need to decrease the text size in a document consistently multiple times - 9 to 8, 10 to 9, 11 to 10 etc. This is an easy find/replace. The trick is that I need to do this in hundreds of documents, but not simultaneously, so the "All documents" option is not applicable.

Is there some kind of "Action consequence" that I can save and run automatically, instead of doing this by hand every time?

Thanks

TOPICS
Scripting
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Dec 14, 2017 Dec 14, 2017

An alert!

Remeber: if you run the code more than one time in the same doc, it'll resize the texts that has already been resized from 11 to 10 and from 10 to 9. And resizes them again to 9 and 8 respectively. The code will work until no texts in 9, 10 or 11 points are found.

Translate
Enthusiast ,
Dec 14, 2017 Dec 14, 2017

Yes. Of course.

The rule is always the same?

Every text with 9pt decrease to 8pt.

Every text with 10pt decrease to 9pt.

Every text with 11pt decrease to 10pt.

Is it?

These sizes occurs in the same document?

It depends on the font type or not?

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2017 Dec 14, 2017

Yes, the rule is always the same, 9->8, 10->9 etc. I need this done in one or more documents at a time. It does not depend on the font, just pure text size change.

Can you explain how to do it? Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 14, 2017 Dec 14, 2017

Making a javascript.

​Depends on your needs, it could be done using:

for (var i=app.activeDocument.stories.length-1; i>=0; i--) {

for (var j=app.activeDocument.stories.paragraphs.length-1; j>=0;

j--) {

app.activeDocument.stories.paragraphs.pointSize =

app.activeDocument.stories.paragraphs.pointSize - 1;

}

}​

In this code we'll find all stories in the current document and all

paragraphs in each story.

For each of those paragraphs, we'll decrease its pointSize by one point.

====================

We can be more specific, finding only texts in 9pt, 10pt and 11pt.

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.pointSize = 9;

app.changeGrepPreferences.pointSize = 8;

app.activeDocument.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

Keep in mind that the codes only deal with pointSize.

In my tests I'm using automatic leading size. If you have a different

leading size, it'll need to be treated too.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2017 Dec 14, 2017

It seems this will do the job. You're great!

The one problem is that I cannot handle this code making it JS.

Can you please explain how to create .jsx file from this code, more specifically from the second part where I can "appFind" a specific size and "appChange" to to another specific size.

I'm sorry for insisting, but I work with Indd only, and I cannot be sure to handle creating the correct jsx file from this code.

Thanks again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 14, 2017 Dec 14, 2017

Just open any text editor, copy and paste the code you want and save the

file as jsx.

You can repeat the entire code to find/change different text sizes.

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.pointSize = 9;

app.changeGrepPreferences.pointSize = 8;

app.activeDocument.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.pointSize = 10;

app.changeGrepPreferences.pointSize = 9;

app.activeDocument.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.pointSize = 11;

app.changeGrepPreferences.pointSize = 10;

app.activeDocument.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2017 Dec 14, 2017

I saved this code as .jsx file:

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.pointSize = 9;

app.changeGrepPreferences.pointSize = 8;

app.activeDocument.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.pointSize = 10;

app.changeGrepPreferences.pointSize = 9;

app.activeDocument.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

app.findGrepPreferences.pointSize = 11;

app.changeGrepPreferences.pointSize = 10;

app.activeDocument.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;


When I load the script and try to run it, an error occurs:

Syntax Error
Line 1


What I'm doing wrong?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 14, 2017 Dec 14, 2017

I don't know. I copied the code you sent, saved as jsx file, put it into

the scripts panel folder and it runs fine.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2017 Dec 14, 2017

Can you please send me your jsx file at vakarelski@gmail.com?

I really like your responsiveness and dedication, I would like to have further business relations with you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2017 Dec 14, 2017

Can you please send me your jsx file at username "vakarelski" in gmail?

I really like your responsiveness and dedication, I would like to have further business relations with you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 14, 2017 Dec 14, 2017

An alert!

Remeber: if you run the code more than one time in the same doc, it'll resize the texts that has already been resized from 11 to 10 and from 10 to 9. And resizes them again to 9 and 8 respectively. The code will work until no texts in 9, 10 or 11 points are found.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 14, 2017 Dec 14, 2017
LATEST

The trick is that I need to do this in hundreds of documents

You can run your script from my Batch processor. BTW, soon I am going to post a new -- a more advanced -- version.

— Kas

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines