• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
6

How to create a Batch Script for InDesign files?

Community Beginner ,
Sep 20, 2023 Sep 20, 2023

Copy link to clipboard

Copied

Apologies if this is a question that has been answered (or is regularly asked)
Wanting to record a set of instructions in an Indesign file like you can do in Photoshop where you could run that as a batch against a folder full of files.

Eg of Instructions would be:
1. Open File

2. Find text eg. 27 July 2023

3. Change text to. eg 12 October 2023

4. Save file

5. Export file as a PDF to a different folder

TOPICS
How to , Scripting

Views

297

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Hi Tim,

InDesign does not have any feature to record an operation. You could use the following code, make the appropriate changes like the path of the INDD and PDF file and also the string to search and the string to use as the replacement.

var doc = app.open("/Users/manan/Downloads/sample.indd")
app.findTextPreferences = app.changeTextPreferences = null
app.findTextPreferences.findWhat = "27 July 2023"
app.changeTextPreferences.changeTo = "12 October 2023"
doc.changeText()
app.findTextPreferences = app.changeTextPreferences = null
doc.exportFile(ExportFormat.PDF_TYPE, "/Users/manan/Downloads/sample.pdf", false)
doc.close(SaveOptions.YES)

 -Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Thank you Manan, and where do I run the script from? Is it somewhere within InDesign or in an external program? New to this type of thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 22, 2023 Sep 22, 2023

Copy link to clipboard

Copied

LATEST

Check out the following article to know about how to run the script

https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/

Also, JS would run both on the MAC as well as WIN so you are good to go

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

@Manan Joshi Appreciate your help.

Is it possible to do a script that will open up multiple InDesign files within a folder and do this?
With the script above you would have to run it individually for each file right?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 22, 2023 Sep 22, 2023

Copy link to clipboard

Copied

Try the following code, it will ask for the folder to scan for InDesign files and will then do the change in any indd file it finds in the folder and exports the pdf with the same name in a folder whose path can be set in the first line of the code

 

var exportFolder = "/Users/manan/Downloads"
var myFolder = Folder.selectDialog("Select a folder with InDesign files");
if (!myFolder)
  exit(0);
var myFileList = myFolder.getFiles();
for (var i = 0; i < myFileList.length; i++) {
    var myFile = myFileList[i];
    var fName = myFile.name.match(/(.*)\.indd$/i)[1]
    if (myFile instanceof File && myFile.name.match(/\.indd$/i)) {
        var doc = app.open(myFile);
        app.findTextPreferences = app.changeTextPreferences = null
        app.findTextPreferences.findWhat = "27 July 2023"
        app.changeTextPreferences.changeTo = "12 October 2023"
        doc.changeText()
        app.findTextPreferences = app.changeTextPreferences = null
        doc.exportFile(ExportFormat.PDF_TYPE, exportFolder + "/" + fName +".pdf", false)
        doc.close(SaveOptions.YES)
    }
}

 

P.S. :- The code to loop over InDesign files in a folder is picked from the following post

https://community.adobe.com/t5/indesign-discussions/open-all-indd-files-from-the-selected-folder/m-p...

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

If you work on a PC - my ID-Tasker is EXACTLY for this.

Even the free version can do this - and WAY more. 

 

▒► ID-Tasker / ID-Tasker Server - work smart not hard ◄▒

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

Thanks Robert, the person I'm trying to help with this works on a PC so much appreciated.

What would someone on a MAC have to use? Just curious.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2023 Sep 21, 2023

Copy link to clipboard

Copied

There are some tools for batch processing - but they are rather limited to a single / specific operation... 

 

With ID-Tasker - you can do whatever you want - and process in the same way - or conditionally - whole servers of files... 

 

▒► ID-Tasker / ID-Tasker Server - work smart not hard ◄▒

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines