To concatenate all your original PDF documents in a single PDF file:

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=single_file.pdf file_1.pdf file_2.pdf ... file_last.pdf


 pdftk file_1.pdf file_2.pdf ... file_last.pdf output single_file.pdf

Now you need to create a PDF that contains only page numbers. In numbers.tex:


(where 31 is your total number of pages.)

Then create numbers.pdf

 pdflatex numbers.tex

Now you need to split your documents to work single page per single page:

 pdftk numbers.pdf burst output number_%03d.pdf
 pdftk single_file.pdf burst output page_%03d.pdf

Now stamp the numbers on the pages:

 for i in $(seq -f %03g 1 31) ; do pdftk page_$i.pdf stamp number_$i.pdf output new_$i.pdf ; done

Alternatively you can try background instead of stamp but for me it didn't work on scanned documents.

And put it all back together:

 pdftk new_???.pdf output single_document_numbered.pdf

Edited 2016-11-17 P. Sunthar wrote me that thanks to multistamp a single command can be used to collate and stamp multiple documents:

 pdftk single_file.pdf multistamp numbers.pdf output single_document_numbered.pdf