Copy link to clipboard
Copied
Hello,
I'm pretty much brand new to JavaScript so forgive me if this seems like a dumb question. But I've got an export script to create two files with specific names from a single InDesign document. The name of the InDesign file is a constant in both files however one needs to contain a variable customer name and the other will always contain "FOX".
The script is currently exporting the files correctly, as well as the naming conventions for everything except the customer name. Currently I have the customer name set up as a text variable in my InDesign template. When I go to export all I get for the customer name pdf is the InDesign file name plus [object TextVariable] instead of the definition I give the variable itself.
What I would like to have on export is
A123456 CUSTOMER.pdf (Customer of course being replaced with the text variable definition)
A123456 FOX.pdf
I'm probably missing something here but I can't figure out what. I've attached some screenshots here for the naming section of the script plus the result. Any advice would be appreciated. Thanks!
Hello @Evan vR,
Give this a try, as it worked for me returing the text from a Type: Custom Text text variable...
var myCustomerName = app.activeDocument.textVariables.itemByName('CustomerName').variableOptions.contents;
Regards,
Mike
It's not free, but Extract Pages - Id-Extras.com (an InDesign add-on/script) does everything you want. It will let you set up, say a GREP find to find whatever text you want on the page, and then create PDFs from each page, with that found text (plus any prefixes and suffixes you want) as the file name... and many more options....
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hello @Evan vR,
Give this a try, as it worked for me returing the text from a Type: Custom Text text variable...
var myCustomerName = app.activeDocument.textVariables.itemByName('CustomerName').variableOptions.contents;
Regards,
Mike
Copy link to clipboard
Copied
Thanks Mike, I reckon your way is better, because it means that you don't have to have used the variable anywhere. Nice. - Mark
Copy link to clipboard
Copied
Thanks Mike,
That worked like a charm!
Copy link to clipboard
Copied
Jumping on this a couple years later to ask, would this be a good way to custom-name data merged documents? I'm doing a data merge and I want to export and name each merge result as its own document. The challenge is, when I run the merge each result just gets a digit. So if the master is "MyDoc.indd", then I get "MyDoc1.indd", "MyDoc2.indd". I could work with this by changing the file name on export to found text, possibly using the above script with a modification to using "found text" rather than a preset variable.
Example: The merge is "Name: <<fname>> <<lname>>"
Result 1 is: "Name: John Smith"
So script would:
1. GREP find: (?<=Name: )(\w.+ \w.+)
2. Export to PDF: "[foundtext].pdf" resulting in "John Smith.pdf"
Would that be possible and/or the best way to do it?
Copy link to clipboard
Copied
Hello @defaultu0e43kqloi6n,
If you goal is to export individual pdfs with unique file names from a merged document, take a look at the post below...
https://community.adobe.com/t5/indesign-discussions/unique-file-names/m-p/11965769
Regards,
Mike
Copy link to clipboard
Copied
Hmm, thanks that's in the right direction, but it looks to want to create a separate PDF from each page. A single record from my data merge takes up 240 pages (it's a book-length document with a lot of custom fields throughout). I'm merging and exporting one record at a time, so automating the steps of File>Export>Interactive PDF>Type in File Name>Export seems like a small thing to automate, but it will save a lot of time over hundreds of records and also help avoid human error in mixing up or mistyping the names.
Copy link to clipboard
Copied
It's not free, but Extract Pages - Id-Extras.com (an InDesign add-on/script) does everything you want. It will let you set up, say a GREP find to find whatever text you want on the page, and then create PDFs from each page, with that found text (plus any prefixes and suffixes you want) as the file name... and many more options....
Copy link to clipboard
Copied
Sorry for the delayed response, but this looks like exactly what I need, thank you!