Batch convert Indesign page size script
Learn / Forums / InDesign User Groups / Batch convert Indesign page size script
- This topic has 22 replies, 2 voices, and was last updated 2 years, 10 months ago by
Babs.
-
AuthorPosts
-
-
June 13, 2019 at 9:56 pm #117162
Tim Coleman
MemberHi, 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. -
June 13, 2019 at 10:26 pm #117163
Jeremy Howard
ParticipantHello 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
-
June 13, 2019 at 10:49 pm #117164
Tim Coleman
MemberHi 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 -
June 13, 2019 at 11:11 pm #117165
Jeremy Howard
ParticipantIf 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 selectionrepeat 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 currentFiletell 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 tellend repeat
-
June 13, 2019 at 11:24 pm #117167
Tim Coleman
MemberOMG 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 -
June 13, 2019 at 11:31 pm #117168
Tim Coleman
MemberAlternatively 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!
-
June 13, 2019 at 11:33 pm #117169
Jeremy Howard
ParticipantAre all of these documents a single page?
-
June 13, 2019 at 11:39 pm #117170
Tim Coleman
MemberYes, 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.
-
June 13, 2019 at 11:58 pm #117171
Tim Coleman
MemberI’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!
-
June 14, 2019 at 12:23 am #117173
Jeremy Howard
ParticipantI’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!
-
June 14, 2019 at 12:02 pm #117181
Jeremy Howard
ParticipantHere 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 selectionrepeat 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 currentFiletell 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 repeattell 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 –InDesignend 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-
November 16, 2021 at 2:26 pm #14350538
Babs
ParticipantHi 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!
-
November 16, 2021 at 2:31 pm #14350541
David Blatner
KeymasterBarbara, will this help?
How to Install a Script in InDesign That You Found in a Forum or Blog Post
-
November 16, 2021 at 2:49 pm #14350542
Babs
ParticipantThank 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
-
November 16, 2021 at 3:08 pm #14350543
David Blatner
KeymasterOne 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.
-
November 16, 2021 at 3:22 pm #14350544
Babs
ParticipantI 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?
-
November 16, 2021 at 3:36 pm #14350547
David Blatner
KeymasterYeah, 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.
-
November 16, 2021 at 4:10 pm #14350548
Babs
ParticipantOkay, 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?
-
November 17, 2021 at 2:50 pm #14350555
David Blatner
KeymasterBabs: 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.
-
April 13, 2022 at 8:33 pm #14364330
Babs
ParticipantThank 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
-
-
June 16, 2019 at 3:55 pm #117198
Tim Coleman
MemberJeremy you are a VERY smart person. THANK YOU!
I’s absolutely BRILLIANT!
:))))
-
June 20, 2019 at 6:55 am #117260
Jeremy Howard
ParticipantHey Tim,
I am so glad to have helped! Hopefully others will find this script useful as well!
-
October 8, 2019 at 4:15 am #14323964
Neil Carter
MemberGuys, 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.
-
-
AuthorPosts
- You must be logged in to reply to this topic.