Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

batch process to add new comment.

Participant ,
Nov 13, 2022 Nov 13, 2022

I have a total of 150 PDFs in a particular folder. If there is no comment in the PDF, then Acrobat should add a new comment "No comment in file". Is there any way or JavaScript to batch process this task on 150+ PDFs?

TOPICS
JavaScript
1.2K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 14, 2022 Nov 14, 2022
LATEST

Hi,

The mikeb41294032's script is correct, but if you use the try catch statment, you don't need to use the if (annots==null) condition.

Here is a script using only the if condition:

 

annots=this.getAnnots();
if (annots==null) {
	var annot=this.addAnnot({
		page: 0,
		type: "Text",
		contents: "No comment in file",
		point: [300,400]
	})
	this.saveAs({cPath: this.path});
}

 

 Then when you run the action wizard, you have to select the folder containing all your 150 files.

@+

View solution in original post

Translate
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
Advisor ,
Nov 13, 2022 Nov 13, 2022

Hello @abhijeett89122812

 

Give this a try...

Start off by creating a new Action, on the top right you will need to point the action to the folder with the files to be processed. Under More tools select/add Execute JavaScript > Specify Setting, paste the below code in the editor window and uncheck Prompt User.

Screen Shot 2022-11-14 at 2.32.42 AM.png

try{ this.syncAnnotScan();
    var annots = this.getAnnots();

    if(annots == null){
     var annot = this.addAnnot ({page: 0, type: "Text", point: [300,400], contents: "No comments in file."});
      app.execMenuItem("Save");
      }
    } catch(e) {
    app.alert(e);
  }

 

Regards,

Mike

Translate
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
Community Expert ,
Nov 14, 2022 Nov 14, 2022
LATEST

Hi,

The mikeb41294032's script is correct, but if you use the try catch statment, you don't need to use the if (annots==null) condition.

Here is a script using only the if condition:

 

annots=this.getAnnots();
if (annots==null) {
	var annot=this.addAnnot({
		page: 0,
		type: "Text",
		contents: "No comment in file",
		point: [300,400]
	})
	this.saveAs({cPath: this.path});
}

 

 Then when you run the action wizard, you have to select the folder containing all your 150 files.

@+

Translate
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