Give this a try..
#target photoshop;
main();
function main(){
if(!documents.length) return;
try{
var path = activeDocument.path;
}catch(e){
alert("This document has not been saved");
return;
}
if(activeDocument.name.toString().toLowerCase().search(/_psd\.psd$/) == -1){
alert("Filename is not in the correct format");
return;
}
var fileName = activeDocument.name.toString().match(/[^_]*/);
var savedState = activeDocument.activeHistoryState;
doAction("savelarge","Action Set");
//////////////////////////////////////////////////////////////////////
SaveJPEG(File(path + "/" + fileName + "_large.jpg"),10);
activeDocument.activeHistoryState = savedState;
savedState = activeDocument.activeHistoryState;
doAction("savesmall","Action Set");
//////////////////////////////////////////////////////////////////////
SaveJPEG(File(path + "/" + fileName + "_small.jpg"),10);
activeDocument.activeHistoryState = savedState;
};
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
};