JSX - Strange behavior with regex and Folder.getFiles() on MacOS Monterey 12.4 Apple M1 Pro
Hi all, encountering some strange behavior with a client's Mac Monterey 12.4 using M1 chip.
Here's the first snippet. On my PC and my Mac (Monterey 12.6, 1.4GHz Quad Core Intel Core 5), everything works fine and the decoded paths look correct. On my client's computer, the path reads like "/Users/usr1/Desktop/subfol1/subfol2:subfol3 : 39". Note the colon between the last and penultimate subfolder, which I suspect is why I am getting "tmp000000001" file names in the while writeln statement.
var fol = Folder.selectDialog("Choose the folder containing the PDFs");
if (!fol || !fol.exists) { return; }
var fs = fol.getFiles();
var i = fs.length;
$.writeln("Number of files in " + decodeURI(fol.fsName) + " : " + i);
var pdfOpts = new PDFSaveOptions();
while(i--) {
$.writeln("Filename: " + decodeURI(fs[i].name));
}
Here is another snippet causing issues. Same situation where my PC and Mac return the updated values split out of the string, whereas client's Mac throws the alert:
var setLayerVals = function(layname, vals) {
var lay = layname.replace(/m/gi,"");
var a = lay.split(",");
var x = a[0].replace(/(\(| )+/gi, "");
var y = a[1].replace(/(\)| )+/gi, "");
x = x.replace("Spot1","");
if (isNaN(x) || isNaN(y)) {
alert("could not set previous spot 1 coordinates " + x + ", " + y + ". Using 0,0 instead");
return;
}
vals.x = Number(x);
vals.y = Number(y);
}
var vals = { x: 0, y: 0 };
var ln = "Spot 1 (0.02mm, -0.06mm)";
setLayerVals(ln, vals);
Not being able to re-create is driving me nuts. Perhaps I should have the client update to 12.6 to see if that solves, but any other thoughts would be appreciated. Thanks.

