// to use this script
// file, scripts, add, on save file, select whatever, bla bla, browse to, .js
// button, add to list
// add (auto tga) to ur psd file, put the psd file, in the location, where the file
// will be saved
// Get the active document
var doc = app.activeDocument;
// Check if the file name includes "Auto TGA"
if (doc.name.indexOf("(Auto TGA)") !== -1) {
//Remove the "Auto TGA" and the ".psd" extension from the active document's name
var fileName = doc.name.replace(".psd","").replace(" (Auto TGA)", "");
// Define the save location
var saveFile = new File(doc.path + "\" + fileName + ".tga");
// Save the active document as a TGA file in the same location as the PSD file
var tgaSaveOptions = new TargaSaveOptions();
tgaSaveOptions.resolution = TargaBitsPerPixels.THIRTYTWO;
tgaSaveOptions.rleCompression = false;
doc.saveAs(saveFile, tgaSaveOptions, true, Extension.LOWERCASE);
}