Skip to main content
Participant
May 3, 2024
Question

How do I open file explorer and get selected file path with JS editor?

  • May 3, 2024
  • 1 reply
  • 296 views

I've been trying to create a script to select a pdf containing the front sides of pages and another pdf containing the backside of pages, then combine them with the proper order.
This is what I have so far:

var myDoc = app.newDoc();

var frontSidePg = "<Path to front side pages pdf>";
var backSidePg = "<Path to back side pages pdf>";

// Only here for getting page count
var fDoc = app.openDoc({
    cPath: frontSidePg
});

// Insert front and back pages in correct order
for (var i=0; i<fDoc.numPages; i++) {
    // Front Pages
    myDoc.insertPages({
        nPage : myDoc.numPages-1,
        cPath : frontSidePg,
        nStart: i
    });
    // Back Pages
    myDoc.insertPages({
        nPage : myDoc.numPages-1,
        cPath : backSidePg,
        nStart: fDoc.numPages-i-1
    });
}

myDoc.deletePages({nStart:0}); // Delete blank initial page

I have other co-workers who will likely be using this script so I can't expect them to manually change the file paths each time.

I've tried things like:

app.execMenuItem("Open");
var frontSidePg = String(this.path);

 But it breaks when I try to get the second document needed.

I can't seem to find anything else in the API documentation to help me here.

This topic has been closed for replies.

1 reply

bebarth
Community Expert
Community Expert
May 4, 2024

Hi,

Where are located both front and back pages?

If they are on a sever disk the path is the same for all users. If they are in local, instead of creating a new doc, you can open

one of them then add the other one and save the combined file with a new name... (is this understandablle???).

@+