There are numbering machines.

I have three: a rubber stamp with four wheels you turn by hand (for a 4 digit number)

A Bates numbering machine that is all-mechanical and offers skip numbering, (so for example you can number the print and the negative sleeves the same number then it advances)

And an electronic stamping Dymo Date/Time Stamper (no model number) that does similar numbering electronically by hammering a rubber stamp band (kind of like a daisy wheel printer but a band instead of a wheel).