How about using Generate Image Assets instead? This feature is amazing but often overlooked.
Enable it from the menu File > Generate > Image Assets;
Rename layers/groups/whatnot to file names and, optionally, add size variables;
Generate will pickup those and export them instantly;
An example. My setup: 2 artboards, some groups and layers: