Skip to main content
Participant
January 5, 2012
Answered

Create separate indesign documents for each page of a document

  • January 5, 2012
  • 2 replies
  • 23256 views

I am converting a print indesign file for use with dps. The problem is DPS wants individual files for each page. Is there a script to take each page and save as an indesign file?

This topic has been closed for replies.
Correct answer myDwayneSmith

G'day

You could start with something like this :

tell application "Adobe InDesign CS4"

    set enable redraw of script preferences to false

    activate

    set dsDoc to active document

    set dsDocProps to properties of document preferences of dsDoc

    set pages per document of dsDocProps to 1

    set dsFilePath to (full name of dsDoc) as text

    set text item delimiters of AppleScript to "."

    set dsFilePath to text 1 thru text item -2 of dsFilePath

    set text item delimiters of AppleScript to ""

    set dsPageCount to (count of pages of dsDoc)

    repeat with w from dsPageCount to 1 by -1

        set dsNewDoc to make new document with properties {document preferences:dsDocProps}

        duplicate page w of dsDoc to after page 1 of dsNewDoc

        set active document to dsNewDoc

        delete page 1 of dsNewDoc

        save dsNewDoc to (dsFilePath & "_" & w & ".indd")

        close active document

        delay 1

    end repeat

    close dsDoc saving no

end tell

m.

Message was edited by: myDwayneSmith

Sorry,  just posted this before seeing the 5.5 thing — should still work if you update the version number in the first line.

You might need to change "set dsFilePath to (full name of dsDoc) as text" to "set dsFilePath to (full name of dsDoc) as string"

2 replies

myDwayneSmithCorrect answer
Inspiring
January 6, 2012

G'day

You could start with something like this :

tell application "Adobe InDesign CS4"

    set enable redraw of script preferences to false

    activate

    set dsDoc to active document

    set dsDocProps to properties of document preferences of dsDoc

    set pages per document of dsDocProps to 1

    set dsFilePath to (full name of dsDoc) as text

    set text item delimiters of AppleScript to "."

    set dsFilePath to text 1 thru text item -2 of dsFilePath

    set text item delimiters of AppleScript to ""

    set dsPageCount to (count of pages of dsDoc)

    repeat with w from dsPageCount to 1 by -1

        set dsNewDoc to make new document with properties {document preferences:dsDocProps}

        duplicate page w of dsDoc to after page 1 of dsNewDoc

        set active document to dsNewDoc

        delete page 1 of dsNewDoc

        save dsNewDoc to (dsFilePath & "_" & w & ".indd")

        close active document

        delay 1

    end repeat

    close dsDoc saving no

end tell

m.

Message was edited by: myDwayneSmith

Sorry,  just posted this before seeing the 5.5 thing — should still work if you update the version number in the first line.

You might need to change "set dsFilePath to (full name of dsDoc) as text" to "set dsFilePath to (full name of dsDoc) as string"

Green4ever
Inspiring
January 6, 2012

Yes. Our fellow scripter wrote a script for this, please check this site more details....

http://www.loicaigon.com/en/auto.php?goTo=2

See to the Extract Pages script (5 th script I think)

Thanks,

Green4ever

Participating Frequently
June 26, 2012

I've downloaded the file that Green4ever suggested, but it doesn't seem compatible with CS5.5.Does any one happen to know if something in the script can be altered so this works on CS5.5?

Thanks -

Known Participant
October 4, 2012

OK — the script I posted is Applescript, not Javascript — so it's only useful if you're on a Mac.

Copy and paste it into AppleScript Editor which you'll find in Appications > Utilities (in older versions of OSX it's called Script Editor and it's in a different folder in Applications)

Change the first line to :

    tell application "Adobe InDesign CS5.5"

and change the 8th line to :

    set dsFilePath to (full name of dsDoc) as string

you might also want to delete this line :

    close dsDoc saving no

You can run it directly from the editor by hitting the green run button at the top (this will help you identify any issues yet to be resolved)

Once you're happy with the way it runs, save it as a script (.scpt) into your Scripts Panel folder (will be somewhere like Applications > Adobe InDesign CS5.5 > Scripts > Scripts Panel)

Then it will be available in your Scripts Panel in InDesign (double click to run)

m.


Is there any chance that someone can point me to a script that would work for a Windows machine?