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

Script to open INDD files, run script, and close

Community Beginner ,
Aug 12, 2013 Aug 12, 2013

Hello, I'm looking for a script that will open a folder of Indesign files, open each one, run a selected script, then close each file.

RIght now I'm using the Batch convert script, to convert INDD to INDD and run the script in between (then I delete the extra INDD file). But I'm trying to eliminate the conversion element, just need the script part of it.

Anyone have any help? Thanks.

TOPICS
Scripting
6.1K
Translate
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

correct answers 1 Correct answer

Enthusiast , Aug 12, 2013 Aug 12, 2013

HI erblo007,

Use the below code may it will helpful for you..

var myFolder = Folder.selectDialog("Select Indesign Folder");

var myIndsnFiles = myFolder.getFiles("*.indd");

for(k=0; k<myIndsnFiles.length; k++)

{

    app.open(myIndsnFiles);

  //Write main part of your script here

    app.activeDocument.close();

    }

If above coding help for you, then please click helpful or correct answers for me.

Thanks in advance

Beginner

Translate
Enthusiast ,
Aug 12, 2013 Aug 12, 2013

HI erblo007,

Use the below code may it will helpful for you..

var myFolder = Folder.selectDialog("Select Indesign Folder");

var myIndsnFiles = myFolder.getFiles("*.indd");

for(k=0; k<myIndsnFiles.length; k++)

{

    app.open(myIndsnFiles);

  //Write main part of your script here

    app.activeDocument.close();

    }

If above coding help for you, then please click helpful or correct answers for me.

Thanks in advance

Beginner

Translate
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 ,
Aug 12, 2013 Aug 12, 2013

Thanks Beginner, this is very close. This script opens all the INDD files but only runs the script on the first one. So, the first file gets processed correctly but the subsequent ones don't. Any ideas?

Translate
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 ,
Aug 12, 2013 Aug 12, 2013

Here's my whole code if it helps. I'm wondering if the script is moving too fast. I think that the first files are still PDFing while the others are opening and closing. Could that be it? I'm not sure why else the for loop for the PDFing is only working on the first file.

var myFolder = Folder.selectDialog("Select Input Folder");

var myIndsnFiles = myFolder.getFiles("*.indd");

var exportPath=Folder("/").selectDlg("Select PDF output folder:");

var pdfPreset = "Press Quality";

for(k=0; k<myIndsnFiles.length; k++)

{

    app.open(myIndsnFiles);

    var jobNumber = "12345";

        for (aPage=0; aPage < app.activeDocument.pages.length; aPage++)

        {

            app.pdfExportPreferences.pageRange = app.activeDocument.pages[aPage].name;

            app.activeDocument.exportFile (ExportFormat.PDF_TYPE, File(exportPath+"/"+jobNumber+"_"+pad(app.activeDocument.pages[aPage].name)+".pdf"), false, pdfPreset);

            function pad (n) {

            return ("00000"+n).slice(-3);

            }

        }

app.activeDocument.close();

}

Translate
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
Advocate ,
Aug 13, 2013 Aug 13, 2013

Hi erblo007,

I ran the above script the out file comes as like this ( "12345_0001.pdf", "12345_0002.pdf", first file process correct, second file "12345_001.pdf", "12345_002.pdf") this your requirement or else?

thx,

csm_phil

Translate
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 ,
Aug 13, 2013 Aug 13, 2013

OK I realized that the script does work as needed! (My test files were all numbered 2-3, so it was overwriting).

This is just what I need, thank you!

Translate
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 ,
Aug 13, 2013 Aug 13, 2013
LATEST

Right now I'm using the Batch convert script, to convert INDD to INDD and run the script in between (then I delete the extra INDD file). But I'm trying to eliminate the conversion element, just need the script part of it.

Just for the record, when you use that batch convert script the way you do, it's really a batch processor. If you apply the script in CS6 to CS6 documents, naturally no conversion takes place.

When you say 'then I delete the extra INDD file', you probably save that InDesign files to a different folder. Just use the same folder for input and output.

But anyway, you found a working solution.

Peter

Translate
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