Skip to main content
andrewn63997035
Participating Frequently
July 22, 2019
Answered

Bridge Script to copy and move first image of filename set?

  • July 22, 2019
  • 1 reply
  • 1215 views

I have a folder with 1000s of images I'd like to grab the first image to make a thumbnail of.

For example, the images are named like this:

228837.jpg

228837a.jpg

228837b.jpg

228837c.jpg

228837d.jpg

I need to figure out a script that would pull the first image (non-alphabetical sequential). In this example, it would be 228837.jpg and would like to select all instances of non-alphabetical sequential and copy it to a folder called "thumbnails".

I've been searching and can't seem to figure it out. I would need it to check the active folder I'm in while in Bridge, and then throw into a sub-folder I'd call thumbnails. Any advice?

This topic has been closed for replies.
Correct answer SuperMerlin

This will create a folder off the selected folder...

#target bridge  

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

copyThumbs = new MenuElement("command", "Copy Thumbnails", "at the end of Tools");

}

copyThumbs .onSelect = function () {

var folder = Folder(app.document.thumbnail.path);

if(!folder.exists){

   alert("You are not in a valid folder. Is this a collection?");

    return;

}

var copyFolder = Folder(folder + "/Thumbnails");

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

var copied =0;

var sels = app.document.visibleThumbnails;

var count = sels.length;

for(var z =0;z<count;z++){

var Name = decodeURI(sels.spec.name.replace(/\.[^\.]+$/, ''));

if(Name.match(/^[-+]?\d*$/)){

    new Thumbnail(sels).copyTo(copyFolder);

    copied++;

    }

}

alert(copied + " Thumbnail copied");

};

1 reply

SuperMerlin
Inspiring
July 22, 2019

Here is a start for you:-

#target bridge  

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

copyThumbs = new MenuElement("command", "Copy Thumbnails", "at the end of Tools");

}

copyThumbs .onSelect = function () {

    //CHANGE FOLDER TO SUIT!!!!!!!!!!!!!!!!!!!!!!

var copyFolder = Folder("/d/thumbnails");

var copied =0;

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

var sels = app.document.visibleThumbnails;

var count = sels.length;

for(var z =0;z<count;z++){

var Name = decodeURI(sels.spec.name.replace(/\.[^\.]+$/, ''));

if(Name.match(/^[-+]?\d*$/)){

    new Thumbnail(sels).copyTo(copyFolder);

    copied++;

    }

}

alert(copied + " Thumbnail copied");

};

andrewn63997035
Participating Frequently
July 22, 2019

Wow! Got it to work, kind of.

The only thing I can't figure out is how to name the folder structure to create the folder in the current directory I'm working in.

For example, I have 100s of folders and would need to have the thumbnail folder become the subdirectory within the folder I'm working in.

SuperMerlin
SuperMerlinCorrect answer
Inspiring
July 23, 2019

This will create a folder off the selected folder...

#target bridge  

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

copyThumbs = new MenuElement("command", "Copy Thumbnails", "at the end of Tools");

}

copyThumbs .onSelect = function () {

var folder = Folder(app.document.thumbnail.path);

if(!folder.exists){

   alert("You are not in a valid folder. Is this a collection?");

    return;

}

var copyFolder = Folder(folder + "/Thumbnails");

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

var copied =0;

var sels = app.document.visibleThumbnails;

var count = sels.length;

for(var z =0;z<count;z++){

var Name = decodeURI(sels.spec.name.replace(/\.[^\.]+$/, ''));

if(Name.match(/^[-+]?\d*$/)){

    new Thumbnail(sels).copyTo(copyFolder);

    copied++;

    }

}

alert(copied + " Thumbnail copied");

};