Batch convert Indesign page size script

Learn / Forums / InDesign User Groups / Batch convert Indesign page size script

Viewing 13 reply threads
  • Author
    Posts
    • #117162
      Tim Coleman
      Member

      Hi, does anyone know how to batch convert multiple InDesign document page sizes? I have thousands of documents that are 51 x 60mm and they need to be converted to 51 x 48mm. I realise it can be done by opening each document and either applying liquid layout or changing the document size or using the page tool but with so may documents I need a way of automating the task. I’ve also tried combining all the documents into a Book file but this doesn’t change the document size for all documents in the book even though they all share the same name Master page. I’m pretty sure it needs to be script. I’m working on a Mac using Adobe CC.
      I’ve sent an email to Peter at [email protected] but not heard back.

    • #117163

      Hello Tim,

      This could certainly be handled by a script but before you start down that path, let’s figure out if this can indeed be done by utilizing InDesign’s book feature (I think you might have had the right idea).

      Open the book that you added all of your documents to.

      Open the document that is being used as your style source. (this will be the document listed in your book with a small icon to left of the name).

      go to the Master page and adjust the page size to your liking and save the document.

      Go to the flyout menu in the book panel and choose “Synchronize Options”.

      Make sure that the “Master Pages” check box is ticked (This is NOT ticked on by default)

      Now synchronize your book by going to the book panel’s flyout menu and choosing “Synchronize Book”.

      If all of your master pages have the same name across all of the documents then that should do it! Spot check a few of your documents to be sure that the change took effect and be sure to let us know if this worked for you.

      Thanks,

      Jeremy

    • #117164
      Tim Coleman
      Member

      Hi Jeremy, thanks for the quick reply. I tried it again abut this didn’t change the page size in the other documents in the book. If you’re sure this works then I can do a restart and try again, but I have tried this several times already. (Mind you I was sure it worked on an early test. This is driving me a bit crazy)

      I’m playing around with a script which is starting to work:

      tell document preferences of front document
      set page height to “48mm”
      set page width to “51”
      set document bleed top offset to “0”
      set document bleed uniform size to true
      end tell

    • #117165

      If you are using AppleScript then make a copy of your files into a new folder (just in case this doesn’t work as expected) and try this “quick and dirty” script that I just wrote up:

      (* select all of the files that you would like to convert *)
      tell application “Finder” to set theFiles to selection

      repeat with currentFile in theFiles

      (* opens each file in the default application – this will be whatever the latest version of InDesign is on your machine *)
      tell application “Finder” to open currentFile

      tell application “Adobe InDesign CC 2018”
      (* repeat/try combo checks to see if the front document is open. As soon as the script can set the active document as a variable this repeat will be exited *)
      repeat
      try
      set myDoc to active document
      exit repeat
      on error
      delay 1
      end try
      end repeat

      (* your preferences here *)
      tell document preferences of myDoc
      set page height to “48mm”
      set page width to “51”
      set document bleed top offset to “0”
      set document bleed uniform size to true
      end tell

      (* Save the document in place and close it *)
      tell myDoc
      save
      close
      end tell
      end tell

      end repeat

    • #117167
      Tim Coleman
      Member

      OMG OMG OMG!
      AWESOME!!! Thanks heaps Jeremy :)))

      This script changes the page size as required. What I need it to do now is move all objects on the page up on the Y Axis: -6mm
      (This is to compensate for the the new page size cropping the top and bottom of the document).

      I basically need the script to:
      Open all InDesign documents
      Resize document page size
      Move objects -6mm
      Save document
      close document

    • #117168
      Tim Coleman
      Member

      Alternatively if the script could set the PAGE size (using the bottom middle reference point) instead of the document size we wouldn’t need to move any of the objects on the page.

      I’ve gotta say how impressed I am with your quick and dirty script!

    • #117169

      Are all of these documents a single page?

    • #117170
      Tim Coleman
      Member

      Yes, each document is a single page. Each page is the same size and all the objects on the page sit on the bottom page margin.

    • #117171
      Tim Coleman
      Member

      I’ve got to go soon Jeremy so if I don’t respond, thanks for all your help. I’ve just found a “Select Objects” script in InDesign scripts that may help. Have a great weekend!

    • #117173

      I’ll take a look at it in the morning. If you want to increase the odds of me figuring something out then send one of the indesign docs to [email protected]

      Have a good weekend!

    • #117181

      Here it is!

      This script will open InDesign documents that you have selected in Finder, open them, resize pages, save and close documents.

      Features:
      • Dynamic movement of page objects to keep them aligned to the bottom margin.
      • Works with unlimited number of documents.
      • Works on unlimited number of pages per document.

      Warning:
      This script saves the document in place so all of the selected InDesign documents will be overwritten. I recommend creating a copy of your files prior to running the script.

      ————————————————————–
      ———————–BEGIN SCRIPT———————–
      ————————————————————–

      (* set new dimensions for the pages that you will be batching *)
      set newDocHeight to 48
      set newDocWidth to 51

      (* select all of the files that you would like to convert *)
      tell application “Finder” to set theFiles to selection

      repeat with currentFile in theFiles

      (* opens each file in the default application – this will be whatever the latest version of InDesign is on your machine *)
      tell application “Finder” to open currentFile

      tell application “Adobe InDesign CC 2018”
      (* repeat/try combo checks to see if the front document is open. As soon as the script can set the active document as a variable this repeat will be exited *)
      repeat
      try
      set myDoc to active document
      exit repeat
      on error
      delay 1
      end try
      end repeat

      tell document preferences of myDoc
      (* get current page dimensions *)
      set startHeight to page height
      set startWidth to page width
      (* set page dimensions to our new dimensions *)
      set page height to ((newDocHeight & “mm”) as string)
      set page width to ((newDocWidth & “mm”) as string)
      end tell

      (* find the distance that the page items should be moved using the “roundThis” handler *)
      set xMovement to my roundThis(((newDocWidth – startWidth) / 2), 4)
      set yMovement to my roundThis(((newDocHeight – startHeight) / 2), 4)

      set docPages to every page of myDoc

      (* repeat through all pages in the document and move page items according to the math above *)
      repeat with thisPage in docPages
      move thisPage’s page items by {xMovement, yMovement}
      end repeat –Doc pages

      (* Save the document in place and close it *)
      tell myDoc
      save
      close
      end tell –myDoc
      end tell –InDesign

      end repeat –Repeat with currentFile in theFiles

      (* handler for rounding decimal places *)
      on roundThis(n, numDecimals)
      set x to 10 ^ numDecimals
      tell n * x to return (it div 0.5 – it div 1) / x
      end roundThis

      • #14350538
        Babs
        Participant

        Hi Jeremy – would it be possible for you to direct me to a resource that will teach me exactly what to do with the text of your script? I have been Googling all afternoon, but not finding any answers on where to place this text to turn it into a script that will run. Thanks for your help!

      • #14350541
        David Blatner
        Keymaster
      • #14350542
        Babs
        Participant

        Thank you for for this resource, David! While I still wasn’t able to get this script to run (not sure why), this is definitely the info I have been searching for. Hopefully, I’ll be able to figure out how to actually make one work one day :P

      • #14350543
        David Blatner
        Keymaster

        One of the most common reasons why scripts don’t run properly is that sites (like ours) converts quotes to curly-quotes and you need to change them all (both single and double quotes) to straight.

      • #14350544
        Babs
        Participant

        I did read that in the troubleshooting section of the link you shared. I used “Plain Text” instead of RTF in Text Edit, so am not sure “curly quotes” would be an issue in the case of Plain Text?

      • #14350547
        David Blatner
        Keymaster

        Yeah, you can have curly quotes even in plain text. Curly quotes is not a function of formatting; they’re completely different characters. It’s tricky.

      • #14350548
        Babs
        Participant

        Okay, thanks, David. I have gone thru and replaced all of them with the proper characters and still getting an error in InD. Is there maybe something else I’m not getting? Like should I be removing the “————————————————————–
        ———————–BEGIN SCRIPT———————–
        ————————————————————–” at the beginning or maybe I should be removing the “directions” in this script – the stuff shown in parentheses? Or maybe there is a command I need to add to the front?

        In all the years I’ve tried, have never had success getting a text script to run (even when following tutorials such as yours), so I feel like *I* must be missing something that is maybe assumed or common knowledge by folks who have done this before?

      • #14350555
        David Blatner
        Keymaster

        Babs: Oh my gosh… how embarrassing… the instructions I gave you were for a Javascript, and Jeremy just kindly pointed to to me offline that this was written in AppleScript! LOL. So this only works on the Mac, to be clear. You can download the script here.

      • #14364330
        Babs
        Participant

        Thank you so much, David. Appreciate your help troubleshooting; I am on a Mac. I have the script loaded into InDesign and selected my files in the Finder, but am still receiving an error.

        Are you (or anyone else here) able to provide any clues based on the error info pasted below?

        _______________________

        AppleScript Error!

        Error Number: -2753
        Error String: The variable s is not defined.

        Engine: Default
        File: /Applications/Adobe InDesign 2022/Scripts/Scripts Panel/Resize inDesign Pages.scpt

    • #117198
      Tim Coleman
      Member

      Jeremy you are a VERY smart person. THANK YOU!

      I’s absolutely BRILLIANT!

      :))))

    • #117260

      Hey Tim,

      I am so glad to have helped! Hopefully others will find this script useful as well!

    • #14323964
      Neil Carter
      Member

      Guys, you need to check this out https://www.maycouk.com/homenew
      It’s been a lifesaver where I work, resizes, saves, multiple Indesign docs, exports, pdf, png or jpg to wherever you want, it’ll drop in translations too.
      Worth every penny. Tell Richard Maycock where you heard this from.

Viewing 13 reply threads
  • You must be logged in to reply to this topic.
>