I (hope) that this is finished and works to your expectations for processing the folder of PDF documents. The first thing you will see when you run it is perhaps the following, and you should just click Allow.

The next thing will be a folder chooser where you pick that folder with your 1000 invoice PDFs. Single-click the folder name, do not double-click into it. Then, the application will set about capturing invoice digits and renaming your existing invoice PDFs to these digits in the same folder location. All totally silent. When it is done processing, you will see the following with different numbers:

Rejected PDFs may because either the invoice number was not found, or it was outside the digit range of 4 - 6 digits. The filename is not changed for rejected PDF and there will be an entry in the report indicating the invoice number (if digits not 4 - 6). The report is now in alphabetic order by original filename making it easier to read.

You will be opening up the Script Editor as before, and copy/pasting the code below into it. Click the compile button, and run it on a folder containing 50 - 100 of your PDFs. Just to see how well it processed them.
Next, you will want to use File menu : Save to preserve the AppleScript source and on that save panel:
- File Format: Text (do not change Line Endings)
- Save As: process_pdfs.applescript
- The location can be your Documents folder or even the Desktop. Your choice.
- Save
Follow this with an option-key + File menu : Save As… because we want to make this a double-clickable application on the Desktop:
- File Format: Application
- Options: unset
- Save As: process_pdfs.app
- Save to your Desktop
- And now Quit Script Editor
You now have a double-clickable application on your Desktop that will process a folder of PDF invoices as your requested.
Code: