• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to promote a certain image to the top of a stack?

New Here ,
Jun 12, 2015 Jun 12, 2015

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?

TOPICS
Scripting

Views

380

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jun 13, 2015 Jun 13, 2015

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

...

Votes

Translate

Translate
Enthusiast ,
Jun 13, 2015 Jun 13, 2015

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();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 15, 2015 Jun 15, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 15, 2015 Jun 15, 2015

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines