Contents
- Introduction
- Basic Custom File Naming
- Overwriting Existing Files
- Advanced Custom File Naming
- Mix and Match
- Errors
- Questions and Comments
Introduction
Extract Pages is a great InDesign script to divide an existing InDesign document into separate pages or groups of pages.
Each page, or group of pages, is saved as a separate file.
The script will produce InDesign, PDF, interactive PDF, JPG and PNG files and any combination of these.
Until version 1.3, the filenames of these newly created files followed a basic pattern that could not be modified by the user.
Starting with version 1.3, the filename pattern can be modified by the user. Some very powerful building blocks allow for a wide variety of filename patterns to be specified easily.
Everything described below is equally applicable whether you are producing PDF, InDesign, PNG or JPEG files. All file-naming options are available for both file formats. For simplicity we presume you are creating InDesign files, but the naming results are identical if your are creating other files from your source file.
For ease of use, a useful “default” filename pattern is also available for users for whom this is sufficient.
This article will describe how to use the advanced filenaming feature of Extract Pages.
Basic Custom File Naming
To use a custom filenaming scheme, select the “Custom” radio button, and type the filenaming scheme you would like to use.
For instance, if you type:
Ace Food
and choose to save each page of a 10-page file as separate files, the file names will become:
Ace Food.indd Ace Food-1.indd Ace Food-2.indd ... Ace Food-9.indd
Overwriting Existing Files
Extract Pages no longer overwrites existing files in the same folder that have the same name.
So if a file called Ace Foods.indd already exists in the selected folder, Extract Pages will automatically modify the name to something that does not exist already: Ace Foods-1.indd.
If, as per the previous example, Ace Foods-1.indd through Ace Foods-9.indd are all used, the first file will be called Ace Foods-10.indd.
The point is that Extract Pages will find a new name for all files, and will no longer overwrite existing files. So if needed, first manually delete all existing files from the selected folder.
Advanced Custom File Naming
In addition to simple custom file names, any of the following special codes can be inserted one or more times into the Custom filename field to create advance naming schemes.
First Page <fp>
The <fp> code will be replaced, for each extracted file, with the name of the first page of that file. For example, typing the following into the Custom field (using the 10-page Ace Foods example mentioned previously):
Ace Foods Page <fp>
will result in the following files:
Ace Foods Page 1.indd Ace Foods Page 2.indd ... Ace Foods Page 10.indd
Last Page <lp>
As with the <fp> code, the <lp> code will be replaced with the name of the last page of the extracted file. For example, if we were to split the Ace Food file into two (pages 1-5, and pages 6-10), typing the following in the Custom field:
Ace Foods Pages <fp>-<lp>
would result in the following 2 files:
Ace Foods Pages 1-5.indd Ace Foods Pages 6-10.indd
File Name <fn>
The <fn> code just inserts the full name of the original file.
So, if the original file was called Ace Foods.indd, and it is divided into 2 sections as above, typing
<fn> Pages <fp>-<lp>
would again result in:
Ace Foods Pages 1-5.indd Ace Foods Pages 6-10.indd
Counter #
The hash sign # can be used as a placeholder for a simple counter. For the first extracted file, it will have a value of 1. For the second, 2, and so on.
Multiple ### can also be used to pad the number with leading zeros. So ### will be replaced with 001 for the first file and 002 for the second, etc.
For example, typing the following into the Custom field
## Ace Foods
will result in
01 Ace Foods.indd 02 Ace Foods.indd
… and so on for each file created.
Conditional Text [ ]
Use square brackets [ ] to mark text as conditional.
Conditional text will only be used if the extracted file contains more than 1 page.
This is useful for sorting out singular/plural issues.
For example, if Ace Foods.indd contains 10 pages, and we want to divide it into 3 files: pages 1-3, page 4, and pages 5-10, we could type the following into the Custom field:
### <fn> Page[s] <fp> [through <lp>]
This would result in the following 3 files:
001 Ace Foods Pages 1 through 3.indd 002 Ace Foods Page 4.indd 003 Ace Foods Pages 5 through 10.indd
Because the 002 file has only a single page (page 4), the “s” after the word “Page” is omitted, as is the entire phrase “through <lp>”, since these were placed inside square brackets.
Section Marker <sm>
Use the <sm> code to insert the contents of the first section marker of the extracted file. (Note: InDesign has two similar fields in the Numbering and Sections window: Section Marker, and Section Prefix. They serve a slightly different purpose. The <sm> code picks up the Section Marker field, not the Section Prefix field!)
Alternate Layout Name <alt>
Use the <alt> code to insert the name of the alternate layout of the extracted file.
Paragraph Style <p:styleName>
Here’s where things start getting really powerful!
What the <p:styleName> tag does, is search each extracted file for the paragraph style specified (replace ‘styleName’ with the name of the desired paragraph style).
The text of the first such paragraph that is found in the extracted file will be inserted where the tag is.
Note: Any characters in the paragraph that are invalid for use as part of a filename will be stripped out of the result.
For example, let’s say we are preparing business cards for the 3 employees of the Ace Food company. We have an InDesign file with 3 pages of cards, one per employee (Mark Smith, Sue Lee, and Joe Levy).
The cards are set up in InDesign so that the employee name has the paragraph style “NameLine” applied to it in each of the three cards.
We now want to split this InDesign file into 3 smaller files, one file per business card, and we want the name of each file to be the name of the employee whose business card it is.
In such a case, typing the following in the Custom field
<p:NameLine>
will result in the following 3 files:
Mark Smith.indd Sue Lee.indd Joe Levy.indd
Of course, it is possible to use multiple paragraph styles as well.
If, for example, we also want to include the employee’s role (which appears on each business card, and has the paragraph style “JobLine” applied to it), we could type:
<p:NameLine> <p:JobLine>
and the 3 files would then be called
Mark Smith CEO.indd Sue Lee VP.indd Joe Levy Food Specialist.indd
Character Style <c:styleName>
The <c:styleName> tag searches each extracted file for the character style specified (replace ‘styleName’ with the name of the desired character style).
For details, see the explanation for the <p:styleName> tag, above, as this tag is identical to that one, except that it uses character styles instead of paragraph styles.
Grep Search <g:searchName>
This is the last, and perhaps the most powerful, of all the building blocks so far.
GREP is an advanced InDesign feature, and if you are not familiar with GREP it is well worth reading up on! However, It is outside the scope of this page to go into the intricacies of GREP, so I am presuming that you are familiar with how to use GREP in InDesign to create a powerful filtered search phrase.
InDesign lets the user save GREP searches for reuse later. All that is needed is to click on the little disc icon in the GREP search window, and type in a name.
This is where the fun begins! You can use one or more GREP searches created previously in InDesign with Extract Pages’ custom naming feature to create a really powerful naming structure!
To do this, use the <g:searchName> tag, and replace “searchName” with the name of your saved GREP expression.
For instance, let’s say you have previously saved a GREP search that finds all underlined text that has the “Address” paragraph style applied to it (presuming you have an “Address” paragraph style in the document, of course). You saved this GREP and called it “FindUnderlinedAddress”.
To use this GREP search with Extract Pages, just type:
<g:FindUnderlinedAddress>
Extract Pages will search each extracted document for the first result of this GREP search, and use it as the file name for that extracted file.
Mix and Match
All the above codes can be used multiple times to create a complex file-naming scheme. For example, typing the following into the Custom field:
### <c:Title> <p:LastName> <g:FirstThreeLettersOfFirstName> <p:CompanyName> Page[s] <fp>[-<lp]
might result in the following file names (of course, this very much depends on the details of the results of the GREP search and contents of the paragraph and character styles for each file in question):
001 Mr Smith Mar Ace Foods Inc Pages 3-10.indd 002 Mrs Sue Lee Top Foods Page 9.indd etc. etc.
Errors
If the custom naming scheme results in a filename that cannot be used by the operating system, Extract Pages will silently save that file with the default naming scheme.
Questions and Comments
Having difficulty putting together the right naming scheme? Post a comment below and we’ll be glad to try and help!
Bahadir BedenlierJuly 26, 2017 1:02 am
Hi,
Thank you for creating such a useful script. This was exactly what I was looking for except with one small feature:
Is it possible to save each page/spread as a separate PDF with their page layout names?
I create multiple alternative layouts of the same or similar designs in variety of sizes. This allows me to edit the master layout and all other layouts update automatically. I name each layout accordingly with their dimensions (e.g. 2x3Necker, 3x4shelftalker, 24x36Poster…so on) Then I need to export these layouts as individual PDFs for different services with proper layout names.
Is this script can do that or it can be added as a feature?
Thank you,
Bahadir
ArielJuly 26, 2017 1:28 am
Hi Bahadir,
(Answer updated July 2018): YES! Extract Pages now allows you to extract PDFs from your source InDesign file, and you can base the filenames of the resulting PDF on a paragraph style, character style, or GREP search. So the filename will reflect the content that appears on the actual page, if you wish.
With a few clicks, you can create PDF files of each spread in your source InDesign file. Each PDF file will be named as desired, and you can even create multiple PDFs of each spread (for example, hi-res and low-res versions) and have them automatically go into the correct folders on your harddrive! 2 or 3 clicks and you’re done!
JulianApril 1, 2020 4:52 pm
Hi there – just bought your Extract Pages script. Really impressive stuff. Can I ask if it’s possible to name extracted pdfs based on their section prefix?
eg I have a bunch of sections in my document with section prefix “FR”, “DE”, “IT” etc. I want to export pdfs for each section named:
file_name FR.pdf
file_name DE.pdf
file_name IT.pdf
etc
Regards,
Julian
ArielApril 1, 2020 5:42 pm
Hi Julian, code (Section Marker) do what you want?
Does the
Ariel
JulianApril 1, 2020 6:22 pm
Hi Ariel, thanks for your quick reply. I’ve tried “” (without quotes) in the File Naming: -> Custom: text box but that is not putting a variable in the output filename. e.g. – I am putting “filename ## ” (without quotes) in the Custom: text box and I get:
filename 01 .pdf
filename 02 .pdf
filename 03 .pdf
etc
Julian
PS – just in case – by “Section Prefix” in my original query I meant the text in Numbering & Section Options->Page Numbering->Section Prefix: box, in case that’s possible
ArielApril 1, 2020 6:27 pm
Hi Julian,
Hmm, I think your comment has been mangled by WordPress. I can’t see anything between the quotes. Perhaps let’s continue by email? admin (at) id-extras.com
As for the Section Prefix issue, I think that the answer is not quite. Extract Pages can insert the section marker into the filename, but not (for now) the section prefix.
JulianApril 1, 2020 6:25 pm
PS – I see WordPress is removing tags – the first “” above should be:
less-than-sign sm greater-than-sign
The filename one should read:
filename ## less-than-sign sm greater-than-sign
ArielApril 1, 2020 6:30 pm
Ok, thanks, that makes it clearer.
Anyway, what you’re getting makes sense, I guess, since the sm marker will insert the section marker, not the section prefix.
Ariel
PS Enclosing the marker in pre tags doesn’t seem to work vis-a-vis WordPress.
JulianApril 1, 2020 6:50 pm
Thanks Ariel – confirming this query resolved by copying the Section Prefix tag in Numbering & Section Options down into the Section Marker: text box.
Thanks for your help with this.
Julian
RoyApril 20, 2020 7:58 pm
Still loving this script. In addition to wanting the ability to save presets of groups of presets, I recently noticed the counter # tag causing me problems. Specifically, when exporting pdfs of #10 or #9 envelopes. Instead of getting Client #10 env Proof, Client #10 env Print, Client #10 env Vendor, I am instead getting Client 110 env Proof, Client 210 env Print, Client 310 Vendor. So now I have to undo what Extract Pages has done to #10. Is there a way to prevent the counter tag from activating when the # is part of the original file name?
Thanks in advance. 🙂
ArielApril 30, 2020 1:07 am
Hi Roy,
Glad you’re loving the script!
But indeed, for now it is impossible to use the # character as part of a file name, unfortunately, as it collides with the “counter” special-character as you have discovered.
In the next update, I will try to add an escape character to make this possible.
Meanwhile, perhaps consider using one of the following workarounds. Instead of a true # sign, how about using this: ⋕ (the ‘equal and parallel to’ sign), or ♯ (the ‘music sharp’ sign), or even ⌗ (the ‘view data square’ sign, whatever that is!)
Thanks,
Ariel
RoyApril 30, 2020 1:19 am
Good suggestions. I’ll give one of those a try for the time being. Thank you.
Ken ShepherdJuly 8, 2020 11:34 pm
Hello,
I have a long datamerge document and I would like to batch extract every 37 pages and name the file with the text in named text container, is this possible? I will buy this script if this is possible.
Thanks,
-ken-
ArielJuly 9, 2020 12:09 am
Hi Ken,
Sounds like it should be possible. (You’ll need to paste in the page ranges manually: 1-37, 38-74, etc.)
Every 37 pages should be extracted, but to what file format? .indd? .pdf? Both are possible, in fact.
And when you say the text is in a named text container, what exactly do you mean? Is it regular plain text in a text frame?
Thanks,
Ariel
Jim DeBoerJuly 15, 2020 3:59 am
Can I export each page as a .PDF, but separate each spread into a folder?
I have 200 spreads with 2 – 6 pages per spread. I’d like each page an individual PDF, but each spread a different folder. Is this possible? Thanks for your help
ArielJuly 15, 2020 4:14 am
Hi Jim,
You can of course export each page as a pdf, and you can also (as a second step) export each spread (as a pdf, or a mini InDesign file), all with very flexible custom naming. But you can’t export each spread into a separate folder, the exported spreads would all land up in the same folder (whichever you choose).
Ariel
Jim DeBoerJuly 15, 2020 4:16 am
How would I get each spread to have a different name? I have the plugin,
ArielJuly 15, 2020 4:24 am
It depends what the name should be. But if the desired name of the file appears somewhere on the spread itself, say as a separate paragraph with its own paragraph style, you could pick up the contents of that paragraph and use it as the file name. See above for more details: https://www.id-extras.com/extract-pages-file-naming-help/#p
Jim DeBoerJuly 15, 2020 4:29 am
The desired name is in a paragraph by itself, with a paragraph style of “Dutch” so I used but it did not work. The paragraph is on the spread, but not on a page. Does it need to be on a page? The file comes out with no name just .pdf, .pdf-1 etc on export.
Thanks
ArielJuly 21, 2020 1:05 pm
Hi Jim,
The paragraph with the name should be somewhere in the extracted file. But if you’ve got two pages, and you export page 1, and the name you want is on page 2, I don’t think it will work.
Ariel