function saveAsJPG(folder, name) {
jpgFile = new File(folder + "/" + name + ".jpg");
if (jpgFile.exists) if (!confirm("Overwrite?\nA file with this name in this location already exists.\nDo you want to overwrite that file?")) return;
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;
activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);
}