Skip to main content
Inspiring
November 9, 2015
Answered

Adding thumbnails to collection

  • November 9, 2015
  • 1 reply
  • 899 views

Hi, working with Adobe Bridge CC on Windows 10 (javascript) - I am trying to add objects to a newly created collection - how do I go about... ?

var myCol = app.createCollection('my new collection');

myCol.add(new Thumbnail(File('/c/folder/pathtomy/file.ai')));

But this doesn't seem to work. I also tried children.push, which didn't work...

This topic has been closed for replies.
Correct answer Pedro Cortez Marques

Hi

Hope it works on windows10... tested on w7

// it creates collection only if it doesn't exist

if (getCollByName('my new collection') == undefined) app.createCollection('my new collection');

// add all selected thumbnails of 'File' kind to the collection (if has any Folder selected, it will work ok but collection don't catch folders)

if (app.document.selectionsLength > 0) {

    app.addCollectionMember(getCollByName('my new collection'), app.document.selections);

}

////////////////////////////////////////////////////////////////

function getCollByName(name) {

    var allColl = app.getCollections();

    for (var a in allColl) {

        if (allColl.name == name) {

            return allColl;

        }

    }

}

Pedro Cortez Marques
Pedro Cortez MarquesCorrect answer
Legend
November 10, 2015

Hi

Hope it works on windows10... tested on w7

// it creates collection only if it doesn't exist

if (getCollByName('my new collection') == undefined) app.createCollection('my new collection');

// add all selected thumbnails of 'File' kind to the collection (if has any Folder selected, it will work ok but collection don't catch folders)

if (app.document.selectionsLength > 0) {

    app.addCollectionMember(getCollByName('my new collection'), app.document.selections);

}

////////////////////////////////////////////////////////////////

function getCollByName(name) {

    var allColl = app.getCollections();

    for (var a in allColl) {

        if (allColl.name == name) {

            return allColl;

        }

    }

}

frax_Author
Inspiring
November 10, 2015

Thanks, that worked!