-
1. Re: Move Master Page to Destination_Doc and Applied Master for Respective Page
BEGINNER_X Jun 2, 2015 9:12 PM (in response to BEGINNER_X)Hi All,
Is there any possibilites to change Numbers into Alphabets?????
Kindly look at line 13 in coding.
var destination_doc = app.activeDocument; var sourceFolder = Folder.selectDialog("Select a folder with source InDesign files."); var fileList = sourceFolder.getFiles(/\.indd$/i); fileList.sort(); // run through each file for ( var i = 0; i < fileList.length; i++ ) { var source_file = fileList[i]; app.open(source_file); app.activeDocument.masterSpreads.item("A-Master").namePrefix = String(i); //this is the code var source_doc = app.documents.item(source_file.name); var sourcePages = source_doc.spreads.item(0); sourcePages.duplicate(LocationOptions.AFTER, source_doc.spreads.item(0)); sourcePages.move(LocationOptions.AFTER, destination_doc.spreads.item(-1)); app.activeDocument.close(SaveOptions.NO); }
Screenshot is like as below:
-
2. Re: Move Master Page to Destination_Doc and Applied Master for Respective Page
Sajeev Sridharan Jun 2, 2015 9:19 PM (in response to BEGINNER_X)Try this,
Change line 13 like below:
app.activeDocument.masterSpreads.item("A-Master").namePrefix = String.fromCharCode(66 + i); //this is the code
-
3. Re: Move Master Page to Destination_Doc and Applied Master for Respective Page
BEGINNER_X Jun 2, 2015 10:21 PM (in response to Sajeev Sridharan)Hi Sajeev(vandy)
After long time.....
Your coding is working like a charm...
A-Z handled rename for only 26 files.
But for my request is handling more than 50 files...
Any possibilities, after complete A-Z, rename into "AA-Master", "BB-Master", CC etc.. (or any other better way)
or
A1-Master, B2-Master etc...
Thanks
-
4. Re: Move Master Page to Destination_Doc and Applied Master for Respective Page
Sajeev Sridharan Jun 2, 2015 11:09 PM (in response to BEGINNER_X)Try this,
var destination_doc = app.activeDocument; var sourceFolder = Folder.selectDialog("Select a folder with source InDesign files."); var fileList = sourceFolder.getFiles(/\.indd$/i); var j=0, k=1; fileList.sort(); // run through each file for ( var i = 0; i < fileList.length; i++ ) { var source_file = fileList[i]; app.open(source_file); if(i<25){app.activeDocument.masterSpreads.item("A-Master").namePrefix = String.fromCharCode(66 + i);} else{j++; app.activeDocument.masterSpreads.item("A-Master").namePrefix = String.fromCharCode(64+j) + String(k);if(j==26){j=0; k++;}} var source_doc = app.documents.item(source_file.name); var sourcePages = source_doc.spreads.item(0); sourcePages.duplicate(LocationOptions.AFTER, source_doc.spreads.item(0)); sourcePages.move(LocationOptions.AFTER, destination_doc.spreads.item(-1)); app.activeDocument.close(SaveOptions.NO); }
-
5. Re: Move Master Page to Destination_Doc and Applied Master for Respective Page
BEGINNER_X Jun 4, 2015 8:18 PM (in response to Sajeev Sridharan)Hi Sajeev,
Sorry for the delayed response ...
Finalize Request is, after complete A-Z, rename into "AA-Master", "BB-Master", CC etc.. (after that AAA, BBB etc...)
Using Your code, I modified as below:
(Is there any better coding??) (so handle any number of files)
var x=0, y=1; var z=0; if(k<26){ app.activeDocument.masterSpreads.item("A-Master").namePrefix = String.fromCharCode(65 + k); } else if(k>25 && k<52){ x++; app.activeDocument.masterSpreads.item("A-Master").namePrefix = String.fromCharCode(64+x) + String.fromCharCode(64+x); } else if(k>51 && k<78){ z++; app.activeDocument.masterSpreads.item("A-Master").namePrefix = String.fromCharCode(64+z) + String.fromCharCode(64+z) + String.fromCharCode(64+z); } //etc..
Thanks in Advance
-
6. Re: Move Master Page to Destination_Doc and Applied Master for Respective Page
BEGINNER_X Jun 5, 2015 7:12 AM (in response to BEGINNER_X)THANKS A LOT SAJEEV!!!!