Skip to main content
Known Participant
March 22, 2021
Question

Creating an Action Wizard Tool to Batch Replace Page(s)

  • March 22, 2021
  • 2 replies
  • 2726 views

Hi all,

 

I wonder if somebody could assist me!

 

My goal:

 

I have about 750 pdf files in Folder A (Old) -  they are all named 3435.pdf, 3436.pdf, 3437.pdf etc.

 

I have the same 750 pdf files in Folder B (New) with identical names, they have been updated with new information (these files are all map images).

 

I dont want to simply overwrite the pdfs in Folder A with Folder B as I will lose all the interactive elements that I have already setup. What I want to do is use the equivalent of the Organize  Pages > Replace tool to replace 3435.pdf (Folder A) with 3435.pdf (from Folder B). Which would leave me with updated files in Folder A containing all the new map image from Folder B, but with all the interactive elements still persisting.

 

From what I understand it is not possible to do this without javascript within the action wizard, however with my little knowledge of javascript I am tripping up trying to create this tool, so far I have come up with the following code, would someone be able to shed any light on wether I am close or a million miles away from my end goal?

 

// Name of current file
var sFileName = this.documentFileName; // get the file name

// This represents Current Map.pdf
this.replacePages({
nPage: 1,
cPath: "D:\2021_Mapbook\ += sFileName", // I am trying to concatenate the current file name to the new folder path so that it will replace this pdf with the pdf  with the latest pdf of the same name
nStart: 1,
nEnd: 1
});

 

Thanks for any assistance, hopefully this makes some sense!

 

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
March 22, 2021

What is the path of Folder B?

Known Participant
March 22, 2021

Hi Bernd,

 

So I have it working for a single pdf if I provide the exact file path which would be this;

 

/* Replace Page */

var sFileName = this.documentFileName; // get the file name

// This represents Current Map.pdf
this.replacePages({
nPage: 0,
cPath: "D:\\2021_Mapbook\\3530.pdf",
nStart: 0,
nEnd: 0
});

 

But I wanted to try and have the wizard run through all the files by concatenatiing the current file name (sFileName) to the cPath, like this;

/* Replace Page */

var sFileName = this.documentFileName; // get the file name

// This represents Current Map.pdf
this.replacePages({
nPage: 0,
cPath: "D:\\2021_Mapbook\\+=sFileName",
nStart: 0,
nEnd: 0
});

 

this gives me an error;


RaiseError: This file cannot be found.
Doc.replacePages:10:Batch undefined:Exec
===> This file cannot be found.

Known Participant
March 22, 2021

D:\\2021_Mapbook\\ is the path to folder B

Known Participant
March 22, 2021

FYI - currently when I try to run this script in the debugger window it is giving me the following error;

 

NotAllowedError: Security settings prevent access to this property or method.
Doc.replacePages:8:Document-Level:1