Create batch of new documents
Learn / Forums / InDesign User Groups / Create batch of new documents
- This topic has 7 replies, 3 voices, and was last updated 3 years, 11 months ago by Al Rosero.
-
AuthorPosts
-
-
July 7, 2016 at 12:35 pm #86356Kathy CoteMember
Hi all,
I do not know at all if what I try to find here can exist. Maybe someone of you knows. Is it possible to have a script that creates several new Indesign documents based on the information from a .txt or .csv file?For exemple, I could have two columns in Excel. One for the width and for the height. The script could read the informations and create new documents, save and name the files with the document size.
I know this is a lot to ask. I wonder if it could be possible because I have more than 300 documents with different formats to create so I try to find a faster way.
Or if you have other options to suggest, I will take it.
thanks again for your help
-
July 8, 2016 at 7:45 am #86365Ari SingerMember
My posts are not going through, so I’ll try one more time:
var file = File.openDialog("Select Your Text File", undefined, false); var folder = Folder.selectDialog("Select the folder where the new documents should be saved"); file.open("r"); var content = file.read().split("\n"); for (var i = 0; i < content.length - 1; i++) { var curLine = content[i].split("\t"); var h = curLine[0]; var w = curLine[1]; docName = h + " x " + w; try { var newDoc = app.documents.add(false); newDoc.documentPreferences.pageHeight = h; newDoc.documentPreferences.pageWidth = w; newDoc.save(new File(folder + "/" + docName + " .indd")); newDoc.close(SaveOptions.no) } catch(myError){} }
-
July 8, 2016 at 8:22 am #86361Ari SingerMember
It takes a tab-delimited text file. The first value is the height, and the second is the width. Only use numbers and don’t add measurement units (such as “mm”). The measurement units will be defined by your InDesign defaults. First the script prompts you to select the text file, and then it prompts you again to select the folder where you want the resulting files to be saved.
–Ari
-
August 15, 2016 at 5:01 am #87491Kathy CoteMember
Hi Ari,
Thank you very much for your help. I really appreciate.
I only have a small problem with the script. I can not make it work.
I was wondering if you could help me with that ?This is the JavaScript Error:
Error Number: 25
Error String: Expected: )Engine: main
Line: 7
Source: for (var i = 0; i < content.length – 1; i++) {Offending Text: ;
Again thank you for everything ;-)
Kathy
-
September 14, 2016 at 12:16 pm #88359Kathy CoteMember
Hi Ari,
I want to say thank you, it works! WOW!The only thing is, I can only use whole numbers. I would like to be able to use example: 45.5 X 45.5
Is it possible ?
Thanks ;-)
-
September 28, 2016 at 11:42 am #88703Kathy CoteMember
I try to modify the code but it seems to be a problem.
I would use a .txt file with 3 columns and to use numbers with decimals.
Ok I added the code to the 3 columns but I do not know how to modify the code to use numbers with decimals. And my other problem is that the script seems to only read the first line in the .txt file. The script does not give me an error but does not work completely.does anyone know?
Example of my text in the .txt file:
33 66 1569
55 22 1256
5.5 10.5 8956
33.5 33.5 5842
33.5 33.5 9856and this is my code:
var file = File.openDialog(“Select Your Text File”, undefined, false);
var folder = Folder.selectDialog(“Select the folder where the new documents should be saved”);
file.open(“r”);
var content = file.read().split(“\n”);for (var i = 0; i < content.length – 1; i++) {
var curLine = content[i].split(“\t”);
var w = curLine[0];
var h = curLine[1];
var c = curLine[2];docName = w + “X” + h + “_” + c ;
try {
var newDoc = app.documents.add(false);
newDoc.documentPreferences.pageHeight = h;
newDoc.documentPreferences.pageWidth = w;
newDoc.save(new File(folder + “/” + docName + “.indd”));
newDoc.close(SaveOptions.no)
} catch(myError){}
} -
September 29, 2016 at 3:43 am #88717Kathy CoteMember
ok everyone, I’m sorry. I saw my error.
Everything works well!Thanks
-
April 20, 2020 at 10:23 am #1239364Al RoseroMember
I found this post very useful, I tried on Indesign CC 2020 and nothing happened, it asked me for the TXT document and for the Document Folder but nothing was created.
-
-
AuthorPosts
- You must be logged in to reply to this topic.