Here is a new version of the script that I previously posted to batch save .TIF files with LZW compression. This version will additionally process .tif files found in all sub-folders under the top-level input folder.
#target photoshop
// USE AT YOUR OWN RISK! TESTED ON MAC PHOTOSHOP CC 2019 ONLY
// Batch save TIF files from top-level and sub-level folders with LZW compression
// community.adobe.com/t5/Photoshop/Want-to-run-batch-process-on-TIFFs-only/m-p/10659870#M268352
// Want to run batch process on TIFFs only
// Special thanks to Paul MR for the recursive folder processing code!
// photoshopgurus.com/forum/threads/batch-and-subfolders.22134/
// batch and subfolders
alert('This script will resave all TIFF files with LZW compression. All sub-folders under the selected input folder will be processed.');
var imageFolder = Folder.selectDialog('Select the top-level folder with TIFF files to process');
var origDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
// Script Execution Timer - Function
var timeDiff = {
setStartTime: function() {
d = new Date();
time = d.getTime();
},
getDiff: function() {
d = new Date();
t = d.getTime() - time;
time = d.getTime();
return t;
}
};
// Script Execution Timer - Start
timeDiff.setStartTime();
if (imageFolder != null) processFolder(imageFolder);
function processFolder(folder) {
var fileList = folder.getFiles()
for (var i = 0; i < fileList.length; i++) {
var file = fileList[i];
if (file instanceof File && file.name.match(/\.tif/i)) {
open(file);
// Start Main Code Block
var saveOpt = new TiffSaveOptions();
saveOpt.imageCompression = TIFFEncoding.TIFFLZW;
var aDoc = app.activeDocument;
aDoc.saveAs(new File(aDoc.fullName), saveOpt);
aDoc.close(SaveOptions.SAVECHANGES);
// End Main Code Block
} else
if (file instanceof Folder) {
processFolder(file);
}
}
}
app.displayDialogs = origDialogs;
// Script Execution Timer - Finish
alert('Batch LZW save completed! ' + '\r' + '(' + timeDiff.getDiff() / 1000 + ' seconds)');
// To Do: It would be nice to add a report on the number of files processed...