Change the way basename is set. Set it to "file_" + m+1
#target photoshop;
var startDisplayDialogs = app.displayDialogs
app.displayDialogs = DialogModes.NO
if (app.documents.length > 0) {
var theFirst = app.activeDocument;
var theDocs = app.documents;
jpgOpts = new JPEGSaveOptions( );
jpgOpts.embedColorProfile = true;
jpgOpts.formatOptions = FormatOptions.STANDARDBASELINE;
jpgOpts.matte = MatteType.NONE;
jpgOpts.quality = 12;
for (var m = 0; m < theDocs.length; m++) {
var theDoc = theDocs[m];
var num = m + 1;
app.activeDocument = theDoc;
theDoc.saveAs((new File("~/Desktop/file_" + num)), jpgOpts, false, Extension.LOWERCASE);
};
app.activeDocument = theFirst;
};