Skip to main content
Participating Frequently
February 9, 2019
Question

Can Bridge show me what collections an image is in?

  • February 9, 2019
  • 2 replies
  • 3003 views

In Bridge CC 2019 I use collections to track track various workflow states, such as which sites I have uploaded an image to.

Thus a single image may be in multiple collections - but I can't see how to determine which collections an image is in. (Other than browsing every collection which would be tedious). Am I missing something?

Ideally I would like the equivalent to the function that is in Photoshop Elements, where a right click on a image gives an option to "Remove from Album" and it shows the albums the image can be removed from.

    This topic has been closed for replies.

    2 replies

    Legend
    February 11, 2019

    Save this script as a ".jsx" file and put it in your Bridge Startup Scripts folder (Preferences->Startup Scripts and click the reveal button.) Relaunch Bridge, select ONE file, and select the command from the Tools menu.

    This will search your collections and show a dialog listing which ones that file is in. Bridge apparently cannot search Smart Collections, not sure if that's a bug or what.

    -------------------------

    #target bridge

    if(BridgeTalk.appName == 'bridge'){

        var newCommand = new MenuElement('command', 'Find in Collections...', 'at the end of Tools');

        }

    newCommand.onSelect = function (){

        collFind();

        }

    function collFind(){

        var foundColl = '';

        var j = 0;

        var k = 0;

        try{

            app.synchronousMode = true;

            if(app.document.selectionsLength != 1){

                alert('Please select one file to search for in Collections.');

                return(false);

                }

            else{

                var sFile = app.document.selections;

                var CollList = app.getCollections();

                var sCollList = app.getSmartCollections();

                for(j=0;j < CollList.length; j++){

                    if(app.isCollectionMember(CollList, sFile[0])){

                        foundColl = foundColl + '\r' + CollList.name;

                        }

                    }

                if(foundColl == ''){

                    alert(sFile.name + ' is not in any Collections');

                    return(true);

                    }

                else{

                    alert(foundColl);

                    }

                }

            app.synchronousMode = false;

            }

        catch(e){

            alert(e + '   ' + e.line);

            return;

            }

        }

    -------------------------

    Participating Frequently
    February 11, 2019

    Thanks. That script is helpful for me.

    I also submitted a Bridge feature request to have the equivalent of the PSE option to Remove from Album.

    Legend
    February 20, 2019

    I don't have time to work on it more, but there are at least two other ways to do this that might work. I'll do some more testing later- I want to include this in my Utility Script Pack if I can get it stable and working faster.


    Ok let's test this one... I'm doing a text search of the actual collection files, not using the built-in features at all. Please test to see how it works.

    ---------------------------------

    /*

    CollectionSearch created by David M. Converse ©2019

    www.lumigraphics.com

    Last updated 2-20-2019

    This script uses Extendscript and ScriptUI to find which collections

    a selected file belongs to and allows the user to delete it from chosen collections.

    Licensed under the Apache License, Version 2.0 (the "License");

    you may not use this file except in compliance with the License.

    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software

    distributed under the License is distributed on an "AS IS" BASIS,

    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

    See the License for the specific language governing permissions and

    limitations under the License.

    */

    #target bridge

    if(BridgeTalk.appName == 'bridge'){

        var FM = new MenuElement('command', 'Find in Collections...', 'at the end of Tools');

        var FC = new MenuElement('command', 'Find in Collections...', 'after Thumbnail/Open', this.menuID);

        }

        var scriptf = File($.fileName);

        var bfo = scriptf.parent.parent;

        var cfo = Folder(bfo + '/Collections/');

    FM.onSelect = function (){

        collFind();

        }

    FC.onSelect = function(){

        collFind();

        }

    function collFind(){

        var foundColl = [];

        var j = 0;

        var k = 0;

        var l = 0;

        try{

            if(app.document.selectionsLength != 1){

                alert('Please select one file to search for in Collections.');

                return(false);

                }

            else{

                var sFile = app.document.selections;

                var collList = app.getCollections();

                app.synchronousMode = true;

                var c = cfo.getFiles();

                for(j = 0; j < c.length; j++){

                    cF = c;

                    cF.open('r');

                    var cChildren = cF.read();

                    cF.close();

                    var matchuri = sFile[0].uri;

                    if(cChildren.search(matchuri) != -1){

                        for(var m = 0; m < collList.length; m++){

                            if((collList.name + '.filelist') == decodeURI(cF.name)){

                                foundColl = collList;

                                k++;

                                }

                            }

                        }

                    }

                app.synchronousMode = false;

                if(foundColl.length == 0){

                    alert(sFile[0].name + ' is not in any collections');

                    return(true);

                    }

                else{

                    var w = new Window('palette', 'Find in Collections', undefined, {closeButton:true});

                    w.preferredSize = [350, 350];

                    g = w.add('group', undefined, '');

                    g.orientation = 'column';

                    g.preferredSize = [300, 200];

                    g.alignChildren = ['fill', 'fill'];

                    s = g.add('statictext', undefined, '', {multiline: true});

                    lb = g.add('listbox', undefined, '', {multiselect:true});

                    lb.preferredSize = [250, 125];

                    for(j=0;j < foundColl.length; j++){

                        lb.add('item', foundColl.name);

                        }

                    s2 = g.add('statictext', undefined, '');

                    g2 = w.add('group', undefined, '');

                    g2.orientation = 'row';

                    g2.preferredSize = [300, 150];

                    g2.alignChildren = ['fill', 'fill'];

                    br = g2.add('button', undefined, 'Remove');

                    b = g2.add('button', undefined, 'Close');

                    s.text = sFile[0].name + ' is in the following collections:';

                    s2.text = 'Select collection(s) and click Remove button to remove ' + sFile[0].name;

                    g.layout.layout(true);

                    g2.layout.layout(true);

                    w.layout.layout(true);

                    w.show();

                   

                    b.onClick = function(){

                        w.close();

                        }

                   

                    br.onClick = function(){

                        var m = 'Remove ' + sFile[0].name + ' from Collections?';

                        if(confirm(m)){

                            var n = 0;

                            var o = [];

                            for(j=0;j < lb.items.length; j++){

                                if(lb.items.selected){

                                    o = foundColl;

                                    o[n+1] = lb.items;

                                    n = n + 2;

                                    }

                                }

                            for(j=0;j < o.length; j++){

                                app.removeCollectionMember(o, sFile[0]);

                                lb.remove(o[j+1]);

                                j++;

                                }

                            }

                        }

                    }

                }

            }

        catch(e){

            alert(e + '   ' + e.line);

            return;

            }

        }

    Stephen Marsh
    Community Expert
    Community Expert
    February 10, 2019

    I am not aware of a method within Bridge.

    Knowing that collections are actually XML plain text files with a .filelist extension and where they are located, one can use a tool that can search the content of the files for a specific image name. In the screenshot below, I have used TextWrangler/BBEdit on the Mac OS:

    Legend
    February 11, 2019

    BBEdit on Mac, Notepad++ on Windows. Do a multi-file search in the Collections folder.