Multiple files depending on page count

We have clients send us multiple pdf files of invoices and statements in random order. We split the files using the account number as the file name, resulting in separate files for each client containing all of their invoices and statements. I combine the resultant files using PDF merge in size order, but now want to use the number of pages in each file as a variable for the file name, so that I get a separate file for all the single pages, 2 pages, 3 pages etc. Can anyone help me.

The following code counts the number of pages in the current job file and stores the value in JobInfo 9.

var myPDF=  Watch.GetPDFEditObject();
myPDF.open(Watch.GetJobFileName(),false);
Watch.SetJobInfo(9,myPDF.Pages().Count());
myPDF.Close();

Hi Thanks Phil, I have copied and pasted the code and get an error saying image

You have to change the language to JavaScript or even better, to Enhanced JavaScript.