Welcome to SolidWorks forums Danny.
I'm not an expert with API so not sure how easy would be to write the code/macro the way you need.
If you can decide which files to export from the folder and put them in a different folder (copy to a different location) then there are lot of macros which can do a batch conversion. If you need a similar macro then try Batch Drawing File Export (STEP) You'll need to edit the macro to save as STL along with STEP.
You might also find this post helpful for your future reference.
You can do that with CrossManager :
You select (or drag & drop) all the SolidWorks files you want to convert, and just have to click on a button to run the conversion in STL or STEP.