What Adobe software are you using? It seems you inadvertently posted in The Lounge which is not specific to any of Adobe's software and isn't for support. Let us know what you are using and a moderator can move your post to the appropriate, product-specific, support forum.
File > Export > Artboards to files
In the background of this feature is script which you can read.
I am using Illustrator CC 2017