Skip to main content
Known Participant
February 11, 2023
Answered

Hyphenation off for multiple files in single action

  • February 11, 2023
  • 2 replies
  • 1420 views

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

This topic has been closed for replies.
Correct answer rob day

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

 

2 replies

rob day
Community Expert
Community Expert
February 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);
    }
}

 

 

Known Participant
February 14, 2023

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

 

 

Known Participant
February 15, 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) {
            doc.stories.everyItem().tables.everyItem().cells.everyItem().texts.everyItem().properties = {hyphenation:false, ligatures:false};
        } 
        doc.close(SaveOptions.YES);
    }
}

 


Awasome, thank you very much "rob day"

Community Expert
February 11, 2023

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-text-box-in-each-file/m-p/12990844#M480070

-Manan

-Manan
Known Participant
February 11, 2023

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

 

m1b
Community Expert
Community Expert
February 11, 2023

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