Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Batch create .article files?

jeffreyp6484616
Level 2
Level 2

Since you can't batch update the files in a folio any longer from within InDesign, is it possible to batch create .article files, preferably from the book palate? (Export as PDF doesn't give the option, at least in CC 2014.)

1 Accepted Solution
Vintage-uk
Employee
Employee

Hi,

You could do this via InDesign scripting.

This sample script will ask you to select a folder and will then generate .article files for all the Indd files in that folder.

You may need to modify this script for your environment and setup.

var srcFolder = Folder.selectDialog("Please select path to the InDesign files"); // get source folder

srcFolderContents = srcFolder.getFiles("*.indd"); // get a list indd file

for (var i = 0, n = srcFolderContents.length; i != n; i=i+1) // for each indd file create an article

{

   var articleName = srcFolder + "/" + srcFolderContents[i].name.replace(".indd",".article");

   var doc = app.open(srcFolderContents[i], false);

   var dpsArticleP= [

    [ "assetformat", "pdf"],           // pdf, png, jpg or auto (auto chooses between png and jpg)

    [ "showprogressbar", false ]     

       ];

    app.exportDpsArticle (File(articleName), doc, dpsArticleP); // export article

    doc.close;

}

25 Replies
Vintage-uk
Employee
Employee

Hi,

You could do this via InDesign scripting.

This sample script will ask you to select a folder and will then generate .article files for all the Indd files in that folder.

You may need to modify this script for your environment and setup.

var srcFolder = Folder.selectDialog("Please select path to the InDesign files"); // get source folder

srcFolderContents = srcFolder.getFiles("*.indd"); // get a list indd file

for (var i = 0, n = srcFolderContents.length; i != n; i=i+1) // for each indd file create an article

{

   var articleName = srcFolder + "/" + srcFolderContents[i].name.replace(".indd",".article");

   var doc = app.open(srcFolderContents[i], false);

   var dpsArticleP= [

    [ "assetformat", "pdf"],           // pdf, png, jpg or auto (auto chooses between png and jpg)

    [ "showprogressbar", false ]     

       ];

    app.exportDpsArticle (File(articleName), doc, dpsArticleP); // export article

    doc.close;

}

jeffreyp6484616
Level 2
Level 2

Thanks. I'll give that a shot.

Of course, that means the DPS Classic file organization--one file per folder--doesn't exactly work with this...

rperez_bonnier
Level 5
Level 5

Is this script able to work with inDesign files in sub-folders as generated by the script available here:

Rapidly create folios using a PDF-to-InDesign script | Adobe Developer Connection

Neil_Enns_-_Ado
Employee
Employee

Challenge accepted Here's a modified version of Rupert's script that loops through the first level of subfolders in your selected starting folder and generates a .article file from the .indd files inside those folders. The resulting .article file is saved into the subfolder.

var srcFolder = Folder.selectDialog("Please select path to the InDesign files"); // get source folder

srcSubfolders = srcFolder.getFiles(onlyFolders);

for (var i = 0, n = srcSubfolders.length; i != n; i=i+1)
{
    srcFolderContents = srcSubfolders[i].getFiles("*.indd"); // get a list indd file
    for (var j = 0, m = srcFolderContents.length; j != m; j=j+1) // for each indd file create an article
    {
       var articleName = srcFolder + "/" + srcSubfolders[i].name + "/" + srcFolderContents[j].name.replace(".indd",".article");
       var doc = app.open(srcFolderContents[j], false);
       var dpsArticleP= [
        [ "assetformat", "pdf"],           // pdf, png, jpg or auto (auto chooses between png and jpg)
        [ "showprogressbar", false ]     
           ];

        app.exportDpsArticle (File(articleName), doc, dpsArticleP); // export article
        doc.close;
    }
}

function onlyFolders(f) {
  if (f.constructor.name == "File") {
    return false;
  } else {
    return true;
  }

Neil

rperez_bonnier
Level 5
Level 5

Thanks Neil!

I'm testing as I type this and it seems to be working!

The only thing I'm noticing at the moment is that all the indd files have lock files (as they do when a user opens the file) and the lock files are remaining in place while the script continues to loop through the rest of the folders.

At the moment I don't know if this is good or bad. Just something curious. Do you think it's leaving the files open in the background until the loop ends? I see the doc.close; statement so it should be closing them.

Just wondering if it is something that can be tweaked or if it's nothing to worry about. I'm testing on CS6 BTW if that helps.

rperez_bonnier
Level 5
Level 5

The script looped successfully and created a corresponding .article file for every inDesign file using CS6.

However the lock files remain and:

- If a user on the same computer that ran the script double clicks one of the inDesign files, the file opens normally--then manually closing the inDesign file will cause the lock file to go away.

- If a user on a computer other than the computer that ran the script double clicks one of the inDesign files (which are on a local server), the inDesign file will not open (as expected) and we get the message regarding someone else using the file.

The copy of inDesign on the "source" computer does not show any open documents.

Almost there! This script will be very very helpful to many folks once it is tweaked.

NMarroquin
Employee
Employee

The lock file issue is because the doc isn't actually closed. Change line 14 from "doc.close;" to "doc.close();" and that will clear that up.

franciscon89715259‌ the script worked fine in with my install. Are you certain the DPS plug-ins are installed?

francisconeto
Level 2
Level 2

Hi Nathan

With Indesign2014, work perfect

In 2015, give error.

Screen Shot 2015-08-26 at 16.50.35.png

And how can i be sure that the plugins is installed correctly?

NMarroquin
Employee
Employee

In InDesign open a document, select "File >Export". In the Format list you should see an entry for "DPS Article".

Screen Shot 2015-08-26 at 8.57.45 AM.png

Also, you should launch Creative Cloud to see if there's an update available. I don't have a screenshot of that handy.

rperez_bonnier
Level 5
Level 5

After adding the parentheses "()" to do "doc.close;" and now having the script read "doc.close();" worked successfully.

All inDesign files in subfolders each now has a corresponding .article file, and all the inDesign files properly closed.

I did get stuck for a while force quitting inDesign and having to close all the files manually. inDesign stopped responding when I tried the script with changes and all the files were open but invisible. After the first force quit all the open files were visible and I closed them all. After that I force quit inDesign a few times and it still would not respond after force quitting. I had to trash the preferences (and save my scripts and workspaces). Back to normal now.

Anyway, thanks! This is great! I'll report back if we run into anything else related to this script.

rperez_bonnier
Level 5
Level 5

Of course the natural follow up topic is...

Batch uploading all these .article files (and their XML metadata) into a single collection in DPS 2015. And or course, for folks who don't have the resources for NRE to use the API.

A ready-made tool or add-on to the Dashboard would be met with great applause and cheer. Drag and drop to the browser would be ideal.

francisconeto
Level 2
Level 2

Don't work in Indesign 2015

Give error in this line:

        app.exportDpsArticle (File(articleName), doc, dpsArticleP); // export article

Ivan_Mironchuk
Employee
Employee

What about adding in an item to also export a page thumbnail that could be used for the article as well? Would something like that work?

doc.exportFile(ExportFormat.PNG_FORMAT, File(path + file + ".png"));
rperez_bonnier
Level 5
Level 5

Yes please!

Thanks Ivan!

Is that statement ready to add and test?

rperez_bonnier
Level 5
Level 5

I tested the script with that statement added and I get an Error 2: path is undefined.

Neil_Enns_-_Ado
Employee
Employee

Ivan's response wasn't actual code, it was just pseudocode for what one might do. Here's an updated script that also exports the InDesign documents to PNG for use as thumbnail images. I also fixed a bug in my previous post that had the exported articles being put at the top level, instead of in each subfolder.

Note that this will export every page in the InDesign document as a PNG. I can't see anywhere in the InDesign automation APIs to make it only export the first page.

Neil

var srcFolder = Folder.selectDialog("Please select path to the InDesign files"); // get source folder

srcSubfolders = srcFolder.getFiles(onlyFolders);

for (var i = 0, n = srcSubfolders.length; i != n; i=i+1)
{
    srcFolderContents = srcSubfolders[i].getFiles("*.indd"); // get a list indd file
    for (var j = 0, m = srcFolderContents.length; j != m; j=j+1) // for each indd file create an article
    {
       var articleName = srcFolder.name + "/" + srcSubfolders[i].name + "/" + srcFolderContents[j].name.replace(".indd",".article");

      var doc = app.open(srcFolderContents[j], false);
       var dpsArticleP= [
        [ "assetformat", "pdf"],           // pdf, png, jpg or auto (auto chooses between png and jpg)
        [ "showprogressbar", false ]     
           ];

        app.exportDpsArticle (File(articleName), doc, dpsArticleP); // export article
        doc.exportFile(ExportFormat.PNG_FORMAT, File(articleName.replace(".article",".png"))); // export thumbnail image
        doc.close();
    }
}

function onlyFolders(f) {
  if (f.constructor.name == "File") {
    return false;
  } else {
    return true;
  }