Custom Script - Serial Number Generator (and batch generator in reply)

Auto generation of serial numbers is already possible through item settings. What’s the use case of the custom script?
Can we auto generate batch numbers in similar way? That will be really useful.