#target photoshop;
app.bringToFront();
main();
function main(){
//// AMEND TO SUIT///////////////////////////////////////////////////////////////////////////
var fontSize = 8; // Font Size
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inputFolder = Folder.selectDialog("Please select the folder with Files to process");
if(inputFolder == null) return;
var fileList = inputFolder.getFiles(/\.(tif)$/i);
app.displayDialogs = DialogModes.NO;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
for(var a =0 ; a<fileList.length;a++){
var file = fileList[a];
open(file);
doc = app.activeDocument;
var res =doc.resolution;
if (res.resolution != 72){doc.resizeImage(undefined, undefined, 72, ResampleMethod.NONE);}
var fontName = "ArialMT";
var textColor = new SolidColor();
textColor.rgb.hexValue = '000000';
var newTextLayer = doc.artLayers.add();
newTextLayer.name="Filename";
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.kind = TextType.POINTTEXT;
newTextLayer.textItem.color = textColor;
newTextLayer.textItem.font = fontName;
newTextLayer.textItem.size = fontSize;
newTextLayer.textItem.contents = app.activeDocument.name.replace(/\.[^\.]+$/, '');
align("AdBt");
align("AdRg");
doc.resizeImage(undefined, undefined, res, ResampleMethod.NONE);
app.activeDocument.close(SaveOptions.SAVECHANGES);
}
preferences.rulerUnits = strtRulerUnits;
function align(method) {
activeDocument.selection.selectAll();
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
try{
executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
}catch(e){}
activeDocument.selection.deselect();
};
};