I need to search through multiple subdirectories, which contain exactly 2 images in each. One original image and one possible updated image.
I then need to compare the 2 imagesnewLayer.blendMode = BlendMode.DIFFERENCE; and log whether there are differences or not.
I cannot figure out how to recurse through subdirectories properly. My current script looks like this:
#target photoshop
function main() {
var errorlog = File(Folder.desktop + "/Test_Log.txt");
var d =new Date;
// errorlog.open('w');// write
errorlog.open('a');// append
errorlog.writeln(d); // date
// This section shows how to set up user selected images
var mySelectFile1 = File.openDialog("Selection prompt");
if(mySelectFile1 != null) app.open(mySelectFile1);
var mySelectFile2 = File.openDialog("Selection prompt");
if(mySelectFile2 != null) app.open(mySelectFile2);
// Making the selected images variables
var doc1 = app.open(mySelectFile1);
var doc2 = app.open(mySelectFile2);
// Selecting entire doc2 image and copying
doc2.selection.selectAll();
doc2.selection.copy();
// Setting doc1 to active document
app.activeDocument = doc1;
// Pasting doc2 into new layer in doc1
var newLayer = doc1.paste();
// Selecting the difference BlendMode option in layers
newLayer.blendMode = BlendMode.DIFFERENCE;
// Checking histogram to see if there is any difference between layers (doc1 as background and doc2 as new layer)
found=0
var histogram = doc1.histogram;
for (var i = 1; i < histogram.length; ++i) {
if (histogram[i] > 0)
found=1
}
// log output
if (found) {
errorlog.writeln(doc1.name + "," + doc2.name + ",Differences_Found")
}
else {
errorlog.writeln(doc1.name + "," + doc2.name + ",Exact_Match")
}
// close all open documents without saving
while (documents.length > 0) {
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
errorlog.close();
errorlog.execute();
return;
}
main ()
Thank you.