Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

An old script for copying labels not working

Explorer ,
Jan 09, 2025 Jan 09, 2025

On a previous PC i made a script to copy labels and ratings from jpg to raw. I made it because I save both raw and jpg when photographing and when I look through Bridge load the jpg faster. So my workflow:

  1. Rate, label, delete jpg
  2. Copy rating etc to raw
  3. Edit the raw-files with high rating

 

But nothing happens when I run this script (except the deselect all, that works). May you tell me why?

 

#target bridge   

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

labelRate = MenuElement.create("command", "Label Rate from JPGs", "at the end of Tools","labelRate");

}

labelRate.onSelect = function () { 

	app.document.deselectAll();
	
	var sels =app.document.getSelection("jpg");

	for(var a in sels){

		var sourceFile = File(sels.spec);

		var destFile = File(sourceFile.toString().replace(/jpg$/i,"arw"));

		if(!destFile.exists) continue;

		var thumb = new Thumbnail(destFile);

		thumb.rating = sels.rating;

		thumb.label = sels.label;

    }

};

 

TOPICS
Batch , How to , Scripting
457
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jan 09, 2025 Jan 09, 2025

There were some minor errors in the code, this corrected version should now work:

/*
https://community.adobe.com/t5/bridge-discussions/an-old-script-for-copying-labels-not-working/td-p/15079694
*/

#target bridge

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

    var labelRate = MenuElement.create("command", "Label Rate from JPGs", "at the end of Tools", "labelRate");

}

labelRate.onSelect = function () {

    app.document.deselectAll();

    var sels = app.document.getSelection("jpg");

    for (var 
...
Translate
Explorer , Jan 16, 2025 Jan 16, 2025

Thank you for taking your time. I didn't get this to work either, but I found the script that does:

 

#target bridge   
if( BridgeTalk.appName == "bridge" ) {  
    labelRate = MenuElement.create("command", "Copy label & rate from JPGs to NEF", "at the end of Tools", "labelRate");
    alert("Menypunkt lagt til, starter programmet");
}


labelRate.onSelect = function () { 
    alert("Starter med å gå gjennom bildene");
    app.document.selectAll();
    var thumbs = app.document.selections;
    for(
...
Translate
Community Expert ,
Jan 09, 2025 Jan 09, 2025

@IngyNorw – Forgive the “obvious" question, however, are you still using .arw files?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 16, 2025 Jan 16, 2025

Thank you! I forgot to tell that I had tried switching arw to nef and png without any luck. But your question made me think and do a search in another old computer, and there I found an updated version. And this works! 😄

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2025 Jan 09, 2025

There were some minor errors in the code, this corrected version should now work:

/*
https://community.adobe.com/t5/bridge-discussions/an-old-script-for-copying-labels-not-working/td-p/15079694
*/

#target bridge

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

    var labelRate = MenuElement.create("command", "Label Rate from JPGs", "at the end of Tools", "labelRate");

}

labelRate.onSelect = function () {

    app.document.deselectAll();

    var sels = app.document.getSelection("jpg");

    for (var a in sels) {

        var sourceFile = File(sels[a].spec);

        var destFile = File(sourceFile.toString().replace(/jpg$/i, "arw"));

        if (!destFile.exists) continue;

        var thumb = new Thumbnail(destFile);

        thumb.rating = sels[a].rating;

        thumb.label = sels[a].label;

    }

};
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 16, 2025 Jan 16, 2025

Thank you for taking your time. I didn't get this to work either, but I found the script that does:

 

#target bridge   
if( BridgeTalk.appName == "bridge" ) {  
    labelRate = MenuElement.create("command", "Copy label & rate from JPGs to NEF", "at the end of Tools", "labelRate");
    alert("Menypunkt lagt til, starter programmet");
}


labelRate.onSelect = function () { 
    alert("Starter med å gå gjennom bildene");
    app.document.selectAll();
    var thumbs = app.document.selections;
    for(var a in thumbs) { //look thru all files
        var selectedFile = thumbs[a].spec;
        var FileName = decodeURI(selectedFile.name); // get file name 
        //if(FileName=="DanceMOves_1202_0433.JPG");{
            //alert(FileName);        
            var etternavn = FileName.slice((FileName.lastIndexOf(".") - 1 >>> 0) + 2); //get file extension
            var gradering = thumbs[a].rating;
            if(etternavn=="JPG" && gradering>0){ //remember to rate those that has a lavel
                var etikettJPG = thumbs[a].label;
                var graderingJPG = thumbs[a].rating;
                //alert(graderingJPG);   
                var RawNavnet = FileName.replace("JPG","NEF");
                }
            //Assuming all images are sortet by name and the jpg is before the nef, the next thumb will be the raw-version of the jpg we just treated
            if(etternavn=="NEF" && FileName==RawNavnet){
                thumbs[a].rating=graderingJPG;  
                thumbs[a].label=etikettJPG;  
            }
        //}
    }
alert("Ferdig nå");
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2025 Jan 16, 2025

The updated code that I posted worked for me in Bridge 2024.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 16, 2025 Jan 16, 2025

I thought it was very odd that it didn't work in my new computer.
This worked:

app.document.deselectAll();

 But after that, nothing happend. (I switched arw with nef).

I'm on Win11 Bridge 2025, version 15.0.2.432

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 16, 2025 Jan 16, 2025
LATEST

I do something similar, this is an adapted script that should work.

#target bridge
if(BridgeTalk.appName == 'bridge'){
    var labelCopy = MenuElement.create('command', 'Copy Labels', 'at the end of Tools'); //create new menu command
    }

labelCopy.onSelect = function(){
    try{
        var thumbs = app.document.thumbnail.children; //get all thumbnails
        var baseName = '';
        var baseLen = 0;
        var i = 0;
        var j = 0;
        for(i = 0; i < thumbs.length; i++){ //iterate through thumbs
            if(thumbs[i].core.itemContent.canDoCameraRaw){ //process RAW files, could also filter on file extension
                baseName = thumbs[i].name.split('.');
                baseLen = baseName.length - 1;
                if(baseName[baseLen] != 'jpg'){
                    baseName.length--;
                    baseName = baseName.join('.');
                    for(j = 0; j < thumbs.length; j++){ //loop through thumbs
                        if(thumbs[j].name == baseName + '.jpg'){ //find matching jpg files
                            thumbs[i].label  = thumbs[j].label; //assign label
                            }
                        }
                    }
                }
            }
        }
    catch(e){
        alert(e + ' ' + e.line);
        }
    }
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines