Skip to main content
Inspiring
Nov 9, 2015 1:17 PM UTC
Answered

Adding thumbnails to collection

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 is closed to new replies. Start a new post to keep the conversation going.
Pedro Cortez Marques
Pedro Cortez MarquesCorrect answer
Legend
Nov 10, 2015 9:54 AM UTC

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;

        }

    }

}

2 replies

Pedro Cortez Marques
Pedro Cortez MarquesCorrect answer
Legend
Nov 10, 2015 9:54 AM UTC

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
Nov 10, 2015 11:07 AM UTC

Thanks, that worked!

Translate