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
Hi @kanagakumar, change the var name in the 2nd for loop from "i" to "j" (5 places). - Mark
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);
}
...
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) {
...
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
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
Copy link to clipboard
Copied
Hi @kanagakumar, change the var name in the 2nd for loop from "i" to "j" (5 places). - Mark
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);
}
}
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);
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);
}
}
Copy link to clipboard
Copied
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);
}
}
Copy link to clipboard
Copied
Awasome, thank you very much "rob day"