Trying to find out if there is a way I can export the pages of an InDesign document so that each exported jpg could have a unique name I am able to specify before exporting, instead of going in afterwards and renaming each one.
You could also try something like Name Mangler http://manytricks.com/namemangler/ to batch rename. It'll save you some time. I often find this easiest.
Here I slapped up a script:
if (app.documents.length != 0) {
var myDoc = app.activeDocument;
var myBaseName = prompt ("Enter basic name", GetFileNameOnly(myDoc.name), "Basic name");
if (myBaseName != null) MakeJPEGfile();
}
else{
alert("Please open a document and try again.");
}
function MakeJPEGfile() {
for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++) {
if (myDoc.pages.item(myCounter).appliedSection.name != "") {
myDoc.pages.item(myCounter).appliedSection.name = "";
}
var myPageName = myDoc.pages.item(myCounter).name;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.medium; // low medium high maximum
app.jpegExportPreferences.resolution = 72;
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
app.jpegExportPreferences.pageString = myPageName;
var myFilePath = "~/Desktop/" + myBaseName + "_" + myPageName + ".jpg";
var myFile = new File(myFilePath);
myDoc.exportFile(ExportFormat.jpg, myFile, false);
}
}
function GetFileNameOnly(myFileName) {
var myString = "";
var myResult = myFileName.lastIndexOf(".");
if (myResult == -1) {
myString = myFileName;
}
else {
myString = myFileName.substr(0, myResult);
}
return myString;
}
Warning! The script removes section prefixes.
Kasyan
Kasyan
RE Export pages to jpg with custom filenames
HELP PLEASE!!
If I have 10 pages in my InDesign document and want to export all 10 pages at once as individualy named JPGs, what do I need to do?
Do I have to use separators in the box that pops up when I execute the script, or amend the script in some way
.
Help would be greatly appreciated as it would save me hours of renaming time when my boss keeps changing his mind!!!
Regards - Janice
That won’t work for me as each page (over 200 of them) have unique names but always get exported with these unique names.
eg bclol2pk.jpg bogofp.jpg and it goes on.
Bridge will defiantly come in handy when I have to add the prefix for each new batch.
The forum: http://forums.adobe.com/message/3063985 seemed to suggest I could run the script that could export each page as a unique JPG name.
Thank you!
Janice
Yes I have, but I don't get a unique name, except for the page number which I don't need. I get something like:
ap11_1.jpg
ap11_2.jpg
ap11_3.jpg
and so on.
So I'm just getting the "Basic Name" which I specified when I ran the script and page names, BUT don't know how to get the unique name for each exported JPG.
Thanks for your help!!
Janice
This would be perfect if I could get it to work.
I just thought that within the script I could add a string so that the script for example would export:
Export page 1 as : ap11_bogofp.jpg
Export page 2 as : ap11_bcolpk.jpg
Export page 3 as : ap11_bcolpkpap.jpg
and so on
Ah well, no harm in asking!!
Thank you for your help!
Kind regards - Janice
jchapmans wrote:
I wouldn't know where to start.
Think it over before asking in the scripting forum. Where would these file names come from?
I just thought that within the script I could add a string so that the script for example would export:
...
Well, where would these additional strings come from? It depends on what you want to use this script for -- if, for example, these postfixes are always these three "bogofp", "bcolpk" and "bcolpkpap", then it's a simple addition to the existing script. However, you say "and so on" so we'd have to know what to append to all other possible pages.
I was able to get this to export in CS4 using the script someone had posted for me. If I remember right, I had to create a new section for each page, and it would read that section marker's label and use it for the jpg's filename. Was VERY handy if you have a portfolio that you want to export each page as jpg with a custom name.
The script had within it a setting for the jpg quality a well, which you would have to change manually within the script (which wasn't terribly difficult).
cdnyc:
See #8-10 for modifying posted script to work in CS5. It's coded to pull from the section name, so nothing you should have to do.
That's not what I see. It appears to simply blank out the section name:
if (myDoc.pages.item(myCounter).appliedSection.name != "") {
myDoc.pages.item(myCounter).appliedSection.name = "";
}John, you are right about that it will blank out the section name. After I have applied new section name this script will in some way reset section name back to "zero".
I would be really greatfull if I could get this script to work with applying the section name, do you have any suggestions how to do this?
First of all, thank you so much for this script. I know next to nothing about scripting, but I was able to modify this to rename our files for ad proofs (we got tired of clients 'cracking' our PDFs for other vendors). I was wondering, is there a way to modify the script so that it saves the exported file into the same folder as the file you're exporting from? We're working from a server, so this would save us a drag & drop each time.
Thanks again.
Sorry to open up this post again, but I really can't get this to work with CS5.5
I also would like to use this script so that I can export each page as a JPG and that it will use the Section prefix as the name for that JPG.
I have the following code in Toolscript:
if (app.documents.length != 0) {
var myDoc = app.activeDocument;
var myBaseName = prompt ("Enter basic name", GetFileNameOnly(myDoc.name), "Basic name");
if (myBaseName != null) MakeJPEGfile();
}
else{
alert("Please open a document and try again.");
}
function MakeJPEGfile() {
for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++) {
/if (myDoc.pages.item(myCounter).appliedSection.name != "") {
myDoc.pages.item(myCounter).appliedSection.name = "";
}
var myPageName = myDoc.pages.item(myCounter).name;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.medium; // low medium high maximum
app.jpegExportPreferences.exportResolution = 72;
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
app.jpegExportPreferences.pageString = myPageName;
var myFilePath = "~/Desktop/" + myBaseName + "_" + myPageName + ".jpg";
var myFile = new File(myFilePath);
myDoc.exportFile(ExportFormat.jpg, myFile, false);
}
//}
function GetFileNameOnly(myFileName) {
var myString = "";
var myResult = myFileName.lastIndexOf(".");
if (myResult == -1) {
myString = myFileName;
}
else {
myString = myFileName.substr(0, myResult);
}
return myString;
}
North America
Europe, Middle East and Africa
Asia Pacific