I see no one has answered; but I see much of the answer is in the superuser article you cited. They show (in one of the answers) a complete batch file for adding the pdf footer.
All you need now is to find the largest file. Elsewhere on stackoverflow there is a script for doing that. I found it here using the search: select file with the largest number of lines.
Do you want someone to do the job for you, as there are plenty of sites that allow you to advertise for a contract programmer! Have a go at calling one batch file from the other and then come back with more questions.