Copy link to clipboard
Copied
Hi,
I'm new at this so bear with me.
I have the following code:
#target bridge |
function StackIt() { | |
var fileList = Folder(app.document.presentationPath).getFiles("*DIFFUSE*"); | |
for(var a in fileList){ | |
var firstFile = decodeURI(fileList.name.match(/[^_]*/)); | |
var filesToStack = Folder(app.document.presentationPath).getFiles("*"+firstFile+"*"); | |
app.document.deselectAll(); | |
for(var s in filesToStack){ | |
app.document.select(new Thumbnail(filesToStack | |
}; | |
app.document.chooseMenuItem("StackGroup"); | |
}; | |
}; |
StackIt();
which works liek a charm.
Now I want to make sure that in all the stacks, the image with the *DIFFUSE* name component is always shown at the top of the stack.
How would I go about that?
...function StackIt() {
var fileList = Folder(app.document.presentationPath).getFiles("*DIFFUSE*");
for(var a in fileList){
var firstFile = decodeURI(fileList.name.match(/[^_]*/));
var filesToStack = Folder(app.document.presentationPath).getFiles("*"+firstFile+"*");
app.document.deselectAll();
for(var s in filesToStack){
app.document.select(new Thumbnail(filesToStack
));if(filesToStack
.name.match(/diffuse/gi)) diff = s;};
app.document.chooseMenuItem("St
Copy link to clipboard
Copied
function StackIt() {
var fileList = Folder(app.document.presentationPath).getFiles("*DIFFUSE*");
for(var a in fileList){
var firstFile = decodeURI(fileList.name.match(/[^_]*/));
var filesToStack = Folder(app.document.presentationPath).getFiles("*"+firstFile+"*");
app.document.deselectAll();
for(var s in filesToStack){
app.document.select(new Thumbnail(filesToStack
));if(filesToStack
.name.match(/diffuse/gi)) diff = s;};
app.document.chooseMenuItem("StackGroup");
app.document.chooseMenuItem('ToggleStackStateOpen');
app.document.deselectAll();
app.document.select(new Thumbnail(filesToStack[diff]));
app.document.chooseMenuItem('PromoteToTopOfStack');
app.document.chooseMenuItem('ToggleStackStateClose');
};
};
StackIt();
Copy link to clipboard
Copied
Hey,
Thanks very much it works perfectly
Out of curiosity: What does the "/gi" in the name.match() mean?
Also is there a way to do it faster? As in processing time.
Copy link to clipboard
Copied
I don't know if there is a faster way, I doubt it.
The "g" means global or more than one occurance of what you are trying to match.
T "i" means ignore case so can be uppercase/lowercase or mixed case.