Those who know me know that I’m a big fan of extending the functionality of apps with miniature programs called scripts. User Charu Rajput was helpful enough to provide the code for a script for this problem right away. So that you don’t have to type the script yourself, you can download it at the link Delete-AI-Artboards .
Once you have downloaded the script, extract the archive and save the JavaScript file with the extension “.jsx” in the Adobe Illustrator app folder under Presets > Your_language_version > Scripts.