javascriptadobeacrobatacrobat-sdk

adobe acrobat - actions or batch sequence - global.FileCnt is undefined


I've tried the following example in the adobe acrobat docu (see code below). However, it never reaches "End Job Code" line. Upon logging, global.FileCnt has always been undefined. Why is that? Isn't it supposed to be populated by the total number of pdfs selected? Am I missing something?

// Begin Job
if (typeof global.counter == "undefined") {
    console.println("Begin Job Code");
    global.counter = 0;
    // insert beginJob code here
}
// Main Code to process each of the selected files
try {
    global.counter++
        console.println("Processing File #" + global.counter);
    // insert batch code here.
} catch (e) {
    console.println("Batch aborted on run #" + global.counter);
    delete global.counter; // so we can try again, and avoid End Job code
    event.rc = false; // abort batch
}
// End Job
if (global.counter == global.FileCnt) {
    console.println("End Job Code");
    // insert endJob code here
    // may have to remove any global variables used in case user wants to run
    // another batch sequence using the same variables, for example...
    delete global.counter;
}

Thanks!


Solution

  • So, it turned out, I need to run two batch sequences for this to achieve.

    1st script - for populating value for global.FileCnt 2nd script - do the process

    https://forums.adobe.com/thread/1851796