Skip to main content
levanterman
New Participant
September 3, 2018
Question

New folder from selected items - in Adobe Bridge

  • September 3, 2018
  • 4 replies
  • 4348 views

Hi

Is there a way to create 'New folder from selected items' in Adobe Bridge (Similar to the Finder functionality on a Mac) ?

Thanks

Nige

This topic has been closed for replies.

4 replies

Braniac
September 11, 2018

After banging on this a bit, try this. It lets you choose a folder and auto-resolves duplicates. It works from a search or collection.

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

#target bridge

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

    selItems = MenuElement.create('command', 'Move Items', 'at the end of Thumbnail');

    }

selItems.onSelect = function(){

    try{

        var thumbs = app.document.selections;

        if(thumbs.length < 1) return;

        var newFolder = Folder.selectDialog('Select Folder');

        if(newFolder == null) return;

        var foldT = new Thumbnail (newFolder);

        app.synchronousMode = true;

        for(var a in thumbs){

            if(thumbs.parent != foldT){

                var copyFile = File(newFolder.fsName + '/' + thumbs.name);

                if(!copyFile.exists){

                    thumbs.moveTo(newFolder);

                    }

                else{

                    var j = 1;

                    while(copyFile.exists){

                        var nSplit = thumbs.name.split('.');

                        ext = nSplit.pop();

                        thumbs.name = nSplit.join('.') +  ' (' + j + ')' + '.' + ext;

                        copyFile = File(newFolder.fsName + '/' + thumbs.name);

                        j = j + 1;

                        }

                    thumbs.moveTo(newFolder);

                    }

                }

            }

        app.synchronousMode = true;

        app.document.chooseMenuItem('Refresh');

        }

    catch(e){

        alert(e + e.line);

        }

    }

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

New Participant
July 29, 2020

Hey @Lumigraphics.
Thanks for the scripts, I was trying to find something like this. I wanted to ask if you could guide me on how to use this script once inside Bridge. I have installed it but I don't still know how to make it run.
I do see the "Move Items" command. As I click on it, rather than making a new folder, it opens a window to choose the location, and as I do that it says - "Reference Error: thumbs.moveTo is not a function33". Do let me know how to get resolve this.
Thanks!

New Participant
July 31, 2020

Try this one instead.

#target bridge

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

selItems = MenuElement.create('command', 'Move Items', 'at the end of Thumbnail');

}

selItems.onSelect = function(){

try{

var thumbs = app.document.selections;
var a = 0;

if(thumbs.length < 1) return;

var newFolder = Folder.selectDialog('Select Folder');

if(newFolder == null) return;

var foldT = new Thumbnail (newFolder);

app.synchronousMode = true;

for(a = 0; a < thumbs.length; a++){

if(thumbs[a].parent != foldT){

var copyFile = File(newFolder.fsName + '/' + thumbs[a].name);

if(!copyFile.exists){

thumbs[a].moveTo(newFolder);

}

else{

var j = 1;

while(copyFile.exists){

var nSplit = thumbs[a].name.split('.');

ext = nSplit.pop();

thumbs[a].name = nSplit.join('.') + ' (' + j + ')' + '.' + ext;

copyFile = File(newFolder.fsName + '/' + thumbs[a].name);

j = j + 1;

}

thumbs[a].moveTo(newFolder);

}

}

}

app.synchronousMode = true;

app.document.chooseMenuItem('Refresh');

}

catch(e){

alert(e + e.line);

}

}


Got it! It works. Thanks for sharing this @Lumigraphics! I also wished to discuss an alternative with you.
Initially, what I had in mind was a little different.
1. I have a folder, say - "XX" with some 100 hundred images.
2. I select a set of images I wish to move within the same Folder - "XX" in Bridge. (I use Bridge in this step as it has color tags and other metadata filters)
3. Press a script
4. It creates a new subfolder (within XX), say - "New Folder", and moves the selected images inside the subfolder.
5. I select another set images and continue the process so it creates - "New Folder (2)", "New Folder (3)".... and so on.

With your script, I have to choose the destination folder every time I wish to move a particular set of images, through the folder dialogue box. That is the one step I wish to automate.

Do you this that this is possible?

Thanks and Regards.

SuperMerlin
Inspiring
September 11, 2018

To use, select your documents then right mouse click "New folder from selected items"

Enter the name for the new folder.

#target bridge;

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

selItems = MenuElement.create("command", "New folder from selected items", "at the end of Thumbnail");

}

selItems.onSelect = function () {

var thumbs = app.document.selections;

if(thumbs.length <1) return;

var win = new Window("palette","New Folder");

win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"});

win.p1.alignChildren="fill";

win.g10 = win.p1.add('group');

win.g10.orientation = "row";

var txt = "New folder from selected items (" + thumbs.length + " items)";

win.g10.et1 = win.g10.add("edittext",undefined,txt);

win.g10.et1.preferredSize=[300,20];

win.g20 = win.p1.add('group');

win.g20.orientation = "row";

win.g20.alignChildren=["fill","fill"];

win.g20.bu1 = win.g20.add("button",undefined,"Create Folder");

win.g20.bu2 = win.g20.add("button",undefined,"Cancel");

win.g10.et1.active=true;

win.g20.bu1.onClick=function(){

var newFolder = Folder(app.document.presentationPath + "/" + win.g10.et1.text);

if(!newFolder.exists) newFolder.create();

win.close(0);

for(var a in thumbs){ thumbs.moveTo(newFolder);}

}

win.g20.bu2.onClick=function(){win.close(2);}

win.show();

};

Braniac
September 11, 2018

If you run this script from a search (and probably from a collection), it will NOT work right.

There are some bugs with presentationPath and it doesn't work with duplicate filenames. I'm afraid it needs some error checking and a way to resolve duplicates, and also a way to check for valid presentationPath.

I ran into a bunch of this with my JPEG multiexport script and had to manually account for edge cases and duplicates

Braniac
September 11, 2018

To elaborate, a collection's presentationPath is the collection file on disk. For special folders (on Windows at least) like Computer or the Libraries, its either a file or a temp folder. For searches and View->Show Items in Subfolders, there is no presentationPath returned.

Even having the user choose a folder won't work if there are duplicate filenames. In that case, the move just won't complete. You have to handle the conflict and rename the dupes or they won't be moved.

Braniac
September 10, 2018

This would be fairly easy to do with a script. Four steps:

Get new folder location and create folder

Get list of files

Move files to new folder

Resolve naming conflicts

I don't have time to write a sample but you can look at the sample scripts from the SDK as a start.

Stephen Marsh
Braniac
September 3, 2018

The JS scripting reference shows NewFolder and MoveTo commands, so I am guessing that this would be a “simple” enough task for those that posses this arcane knowledge to create a one click script.

Otherwise it would be a manual 2 step process using built in methods:

levanterman
New Participant
September 5, 2018

Thanks Stephen , I haven't done any scripting with Bridge yet, but i'll investigate, I know Javascript. Thanks