Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to take an existing script and apply it to multiple documents

Community Beginner ,
Jan 31, 2018 Jan 31, 2018

Copy link to clipboard

Copied

I would like to take an existing script, but have it run on multiple documents that I have open (or select from a set of unopened files)

For example, run the ExportAllStories.jsx on multiple documents

Is there a chunk of text I can just copy and paste into it to make this happen?

TOPICS
Scripting

Views

436

Likes

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
Enthusiast ,
Jan 31, 2018 Jan 31, 2018

Copy link to clipboard

Copied

When I need something like this, I use this code I wrote sometime ago...

TO RUN IN FILES SAVED IN A FOLDER:

//=============================================================

//  Script by Luis Felipe Corullón

//  Contato: lf@corullon.com.br

//  Site: http://lf.corullon.com.br

//=============================================================

var myFileFolder = Folder(/*HERE GOES THE DEFAULT FOLDER*/).selectDlg("Select the folder.");

var myDialog = myFileFolder;

if (myDialog != null) {

    var myIDFiles = myFileFolder.getFiles("*.indd");

    alert (myIDFiles.length + " files were found in the selected.","Script by LFCorullón");

    for (var z = 0; z < myIDFiles.length; z++) {

        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

        app.open(File(myIDFiles));

//~ =========================================================================================================

//~ =========================================================================================================

// HERE GOES THE CODE TO BE EXECUTED IN EACH FILE

       

// HERE GOES THE CODE TO BE EXECUTED IN EACH FILE

//~ =========================================================================================================

//~ =========================================================================================================

        app.activeDocument.close(SaveOptions.YES);

        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

        }

    }

TO RUN IN FILES SAVED IN A FOLDER AND ALL SUBFOLDERS:

//=============================================================

//  Script by Luis Felipe Corullón

//  Contato: lf@corullon.com.br

//  Site: http://lf.corullon.com.br

//=============================================================

var myFolder = Folder(/*the specified folder here*/).selectDlg("Select the main folder.");

// se o usuário pressionar OK na JANELA DE DIALOGO

var myDialog = myFolder;

if(myDialog == null){

        alert ("Canceled.","Script by LFCorullón");}

else {

    var myFiles = [];

    GetSubFolders(myFolder);

    alert (myFiles.length + " files found in the main folder and subfolders.","Script by LFCorullón");

//open files in the selected folder and subfolders

for(var i = 0; i < myFiles.length; i++)

    {

//não exibe nenhuma janela de interação.

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

//turn check links off

app.linkingPreferences.checkLinksAtOpen = false;

    app.open(File(myFiles));

//~ =========================================================================================================

//~ =========================================================================================================

// EXECUTA A AÇÃO EM CADA UM DOS ARQUIVOS DA PASTA SELECIONADA

       

       

// EXECUTA A AÇÃO EM CADA UM DOS ARQUIVOS DA PASTA SELECIONADA

//~ =========================================================================================================

//~ =========================================================================================================

//turn check links on again

app.linkingPreferences.checkLinksAtOpen = true;

//exibe todas as janelas de interação.

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

    }

alert (myFiles.length + " files in the main folder and subfolders were processed.","Script by LFCorullón");}

function GetSubFolders(theFolder) { 

     var myFileList = theFolder.getFiles(); 

     for (var i = 0; i < myFileList.length; i++) { 

          var myFile = myFileList

          if (myFile instanceof Folder){ 

               GetSubFolders(myFile); 

          } 

          else if (myFile instanceof File && myFile.name.match(/\.indd$/i)) { 

               myFiles.push(myFile); 

          } 

     } 

}

Hope it help.

Likes

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
Valorous Hero ,
Feb 01, 2018 Feb 01, 2018

Copy link to clipboard

Copied

You may be interested by Kasyan Servetsky​ Batch process Script:

Batch processor

Likes

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
Adobe Community Professional ,
Feb 01, 2018 Feb 01, 2018

Copy link to clipboard

Copied

LATEST

Or Peter Kahrel's

Free script Batch convert/export InDesign documents | Peter Kahrel

where you can use its "Run a script" function.

Regards,
Uwe

Likes

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