Replies: 3 comments 2 replies
-
@Roulyoung, if I remember correctly this is needed to sort the files alphanumerically and it's a fairly new method in Photoshop. I guess it was added in CC. The quick and dirty fix would be to replace the lines return inputFiles; This will ignore any kinda sorting with the input files, so if your mockup has multiple smart objects to replace, it won't be able to make sure the images are processed in the right order, but it should work otherwise.
This would likely be the best fix, assuming it works (not tested). It should retain the same behavior provided by
function sortAlphaNum(a,b) {
var reA = /[^a-zA-Z]/g;
var reN = /[^0-9]/g;
var AInt = parseInt(a, 10);
var BInt = parseInt(b, 10);
if ( isNaN(AInt) && isNaN(BInt) ) {
var aA = a.replace(reA, "");
var bA = b.replace(reA, "");
if ( aA === bA ) {
var aN = parseInt(a.replace(reN, ""), 10);
var bN = parseInt(b.replace(reN, ""), 10);
return aN === bN ? 0 : aN > bN ? 1 : -1;
}
else {
return aA > bA ? 1 : -1;
}
}
else if ( isNaN(AInt) ) {
return 1;
}
else if ( isNaN(BInt) ) {
return -1;
}
else {
return AInt > BInt ? 1 : -1;
}
}
return inputFiles.sort(function (a, b) {
return sortAlphaNum(a.name, b.name);
}); |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Last night I (finally) fixed both of the issues raised in this discussion in v.1.6. (7b1d377).
|
Beta Was this translation helpful? Give feedback.
-
Dear Joonas,
Very excited to have found your script and cant wait to use it! Unfortunately, I got an error message:
Error 24: app.Comparewithnumbers is not a function
Line 231: return app.Comparewithnumbers(a.name, b.name)
I am using CS6 and I downloaded the standalone package you provided and tested everything as you specified.
I tried to play around a bit with the code on that specific line but since Im not a coder it was quite futile.
Would be very much appreciated if you know what might be the cause of error!
Beta Was this translation helpful? Give feedback.
All reactions