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

Hyphenation off for multiple files in single action

Participant ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

Dear Experts,

 

I need help from you,

I want to open all of the indesign files in a specific folder and then run the comment.

However, my script only opens a single indesin file. I want to open multiple files in a single action.

Could you please advise on the following:

 

var myDoc = app.open (new File ("D:\\work\\KK\\PDF exportor\\IN\\test.indd"))
alert ("opened the document")
var myParStyles = myDoc.allParagraphStyles;
for (i = 1; i < myParStyles.length; i++) {
myParStyles[i].ligatures = false;
myParStyles[i].hyphenation = false;
}
alert ("process completed")

 

Thanks in advance

Kanagakumar

TOPICS
Scripting

Views

475

Translate

Translate

Report

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 3 Correct answers

Community Expert , Feb 10, 2023 Feb 10, 2023

Hi @kanagakumar, change the var name in the 2nd for loop from "i" to "j" (5 places). - Mark

Votes

Translate

Translate
Community Expert , Feb 11, 2023 Feb 11, 2023

Hi @kanagakumar , If you only need to unconditionally change the documents’ paragraph styles you should be able to skip the 2nd loop using everyItem():

 

 

var sourceFolder = Folder.selectDialog("select a folder");
if (sourceFolder) {
    var myFiles = sourceFolder.getFiles("*indd");
    for (i = 0; i < myFiles.length; i++) {
        var doc = app.open(myFiles[i]);
        doc.paragraphStyles.everyItem().properties = {hyphenation:false, ligatures:false}
        doc.close(SaveOptions.YES);
    }
...

Votes

Translate

Translate
Community Expert , Feb 14, 2023 Feb 14, 2023

Try this:

 

 

var sourceFolder = Folder.selectDialog("select a folder");
if (sourceFolder) {
    var myFiles = sourceFolder.getFiles("*indd");
    for (i = 0; i < myFiles.length; i++) {
        var doc = app.open(myFiles[i]);
        doc.paragraphStyles.everyItem().properties = {hyphenation:false, ligatures:false};
        doc.stories.everyItem().texts.everyItem().properties = {hyphenation:false, ligatures:false};
        if (doc.stories.everyItem().tables.everyItem().getElements().length) {
   
...

Votes

Translate

Translate
Community Expert ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

Try the following code

var sourceFolder = Folder.selectDialog("select a folder");
// check if sourceFolder isn't null/undefined/zero
// it will be null if user cancelled select dialog
if (sourceFolder) {
    var myFiles = sourceFolder.getFiles("*indd");
    for (i = 0; i < myFiles.length; i++) {
        // store the opened document in variable
        var doc = app.open(myFiles[i]);
        var myParStyles = doc.allParagraphStyles;
        for (i = 1; i < myParStyles.length; i++) {
            myParStyles[i].ligatures = false;
            myParStyles[i].hyphenation = false;
        }
    }
}

P.S. :- The code for opening the file from a folder is picked from the snippet shared by @m1b in the post https://community.adobe.com/t5/indesign-discussions/open-all-indd-files-from-a-folder-and-create-a-t...

-Manan

Votes

Translate

Translate

Report

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
Participant ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

Dear Mannan Joshi

Thank you for your coding.

It opens the folder, but only one file is displayed; multiple files cannot be displayed.

I require multiple files to be open in a single action.

After run the coding and then close the all documents. Is it possible?

 

Thanks in advanse

 

Votes

Translate

Translate

Report

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 Expert ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

Hi @kanagakumar, change the var name in the 2nd for loop from "i" to "j" (5 places). - Mark

Votes

Translate

Translate

Report

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 ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

The issue is i being used for 2 loops. Try this:

var sourceFolder = Folder.selectDialog("select a folder");
// check if sourceFolder isn't null/undefined/zero
// it will be null if user cancelled select dialog
if (sourceFolder) {
    var myFiles = sourceFolder.getFiles("*indd");
    for (i = 0; i < myFiles.length; i++) {
        // store the opened document in variable
        var doc = app.open(myFiles[i]);
        var myParStyles = doc.allParagraphStyles;
        for (ii = 1; ii < myParStyles.length; ii++) {
            myParStyles[ii].ligatures = false;
            myParStyles[ii].hyphenation = false;
        }
// Brings up save dialog on close:
doc.close(SaveOptions.ASK);
// To save automatically on close, instead use:
// doc.close(SaveOptions.YES);
    }
}

Votes

Translate

Translate

Report

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 ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

This solution should also close each doc. It will bring the save dialog up on each close. To automatically save on close, make sure to change this line:

doc.close(SaveOptions.ASK);

To this:

doc.close(SaveOptions.YES);

 

Votes

Translate

Translate

Report

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 Expert ,
Feb 11, 2023 Feb 11, 2023

Copy link to clipboard

Copied

Hi @kanagakumar , If you only need to unconditionally change the documents’ paragraph styles you should be able to skip the 2nd loop using everyItem():

 

 

var sourceFolder = Folder.selectDialog("select a folder");
if (sourceFolder) {
    var myFiles = sourceFolder.getFiles("*indd");
    for (i = 0; i < myFiles.length; i++) {
        var doc = app.open(myFiles[i]);
        doc.paragraphStyles.everyItem().properties = {hyphenation:false, ligatures:false}
        doc.close(SaveOptions.YES);
    }
}

 

 

Votes

Translate

Translate

Report

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
Participant ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

Dear "GudgeUK" and "rob day"

Your coding is sufficient to work only for paragraph styles. The manual hyphenation option was not disabled. Kindly suggest.

Please see the attached screen shot.

 

Thanks in advance

kanagakumar

 

 

Votes

Translate

Translate

Report

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 Expert ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

Try this:

 

 

var sourceFolder = Folder.selectDialog("select a folder");
if (sourceFolder) {
    var myFiles = sourceFolder.getFiles("*indd");
    for (i = 0; i < myFiles.length; i++) {
        var doc = app.open(myFiles[i]);
        doc.paragraphStyles.everyItem().properties = {hyphenation:false, ligatures:false};
        doc.stories.everyItem().texts.everyItem().properties = {hyphenation:false, ligatures:false};
        if (doc.stories.everyItem().tables.everyItem().getElements().length) {
            doc.stories.everyItem().tables.everyItem().cells.everyItem().texts.everyItem().properties = {hyphenation:false, ligatures:false};
        } 
        doc.close(SaveOptions.YES);
    }
}

 

Votes

Translate

Translate

Report

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
Participant ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

LATEST

Awasome, thank you very much "rob day"

Votes

Translate

Translate

Report

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