Help me to turn this Javascript to the Hazel system

I find the following script here:https://stackoverflow.com/questions/35001831/how-to-check-multiple-pdf-files-for-annotations-comments:
it is very effective script.
What it does is identify annotated pdf files and moves them to a specific folder.
I want to use it inside hazel to tag pdf files which have annotations (rather than moving them to a specific folder.).
I tried to adopt it as follows:
But, I am not getting a result. I am not good with scripts. Can you help me please?
- Code: Select all
this.syncAnnotScan();
var annots = this.getAnnots();
var fname = this.documentFileName;
fname = fname.replace(",", ";");
var errormsg = "";
if (annots) {
try {
this.saveAs({
cPath: "/c/folder/"+fname,
bPromptToOverwrite: false //make this 'true' if you want to be prompted on overwrites
});
} catch(e) {
for (var i in e)
{errormsg+= (i + ": " + e[i]+ " / ");}
app.alert({
cMsg: "Error! Unable to save the file under this name ('"+fname+"'- possibly an unicode string?) See this: "+errormsg,
cTitle: "Damn you Acrobat"
});
}
;}
annots = 0;
it is very effective script.
What it does is identify annotated pdf files and moves them to a specific folder.
I want to use it inside hazel to tag pdf files which have annotations (rather than moving them to a specific folder.).
I tried to adopt it as follows:
- Code: Select all
theFile.syncAnnotScan();
var annots = theFile.getAnnots();
if (annots==null || annots.length==0) return false;
else return true;
But, I am not getting a result. I am not good with scripts. Can you help me please?