Link in Zwischenablage kopieren
Kopiert
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.
Link in Zwischenablage kopieren
Kopiert
can you try the below with and without decoreURI(uri)?
fol.fullName
fol.fsName
fol.absoluteURI
Link in Zwischenablage kopieren
Kopiert
Hi brian,
The second part is not complete. I am also not sure about the undefined variable "layname".
But could it be that the function call should look more like this?
//setLayerVals(layname, vals);
setLayerVals(ln, vals);
Link in Zwischenablage kopieren
Kopiert
Thanks. I updated the code to pass the correct variable. I retyped it for here; this function is part of a larger operation in the real code
Link in Zwischenablage kopieren
Kopiert
Hi brian,
your change was not sufficient to test the code.
So anyone should be able to test your code:
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 = mmToPoints(Number(x));
vals.y = mmToPoints(Number(y));
}
var vals = { x: 0, y: 0 };
var ln = "Spot 1 (0.02mm, -0.06mm)";
setLayerVals(ln, vals);
function mmToPoints(z) {
z *= 0.3527777778;
return z;
}
But I don't have a Mac, so I don't understand what specific problem this code causes.
Link in Zwischenablage kopieren
Kopiert
Hi @brian_p_dts, regardless of your code, you mustn't use colons in file paths on MacOS. You can read some commentary here and here. Colons have historically been used on MacOS file systems as delimiters and they still get special treatment. I strongly suggest you avoid using them.
- Mark
Edit: From reading your post again, I'm not sure that you *are* using colons. It seems that one is just appearing. This could be a bug in that particular MacOS version (or ExtendScript). When I run the files code on MacOS 13.4.1 I can't reproduce.
Link in Zwischenablage kopieren
Kopiert
Correct. There is no colon in the filepath. It's introducing one.
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen