var uMargin = new UnitValue("170 pixels");
var dir = new Folder("D:\\ImagesFolder");
app.playbackDisplayDialogs = DialogModes.NO;
if (dir != null) {
var fileList = dir.getFiles("*.jpg");
for (var i = 0; i < fileList.length; i++) {
try {
open( fileList[i] );
app.activeDocument.resizeCanvas(app.activeDocument.width,app.activeDocument.height+uMargin,AnchorPosition.TOPCENTER);
app.activeDocument.save(SaveOptions.SAVECHANGES);
app.activeDocument.close();
}
catch(e) {
// бла-бла
}
}
}