Skip to main content
Known Participant
January 14, 2011
Question

Script problem with path (CS3 JS)

  • January 14, 2011
  • 1 reply
  • 1653 views

Hi -- I have written a script that launches from InDesign then goes to Bridge. A boiled down version is below. What I am finding is this script works perfectly as long as the folder I am referring to is the last one accessed by Bridge. If it was a different folder, bridge stills fires up and selects the desired thumbnail but then stops. The next time I run it, it works fine as long as I am accessing that same folder (the one that failed the first time). Any ideas would be greatly appreciated.

var myPath = "C:\\myfolder\\mypic.jpg";

var bt = new BridgeTalk;

   bt.target = "bridge";   
   
   var myScript = 'app.document.thumbnail = new Thumbnail(File("' + myPath + '"));\n';
        
   myScript += 'var sels = app.document.selections;\n';
  
   myScript += 'for( var i = 0; i < sels.length; ++i ) {\n';
  
   myScript +=     'var md = sels.synchronousMetadata;\n';
  
   myScript +=     'app.synchronousMode = true;\n';
  
   myScript +=     'md.namespace = "http://ns.adobe.com/photoshop/1.0/";\n'
     
   myScript +=     'md.Caption = "This is my caption text test";\n';
  
   myScript +=     '};\n';
  
   bt.body = myScript;

   bt.send();

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
January 14, 2011

To be honest I can't see this script ever working, as yes you can change to the folder you want but then you are not making any selections so there is nothing to process.

jmw107Author
Known Participant
January 14, 2011

Yep, I thought it was quite odd that this worked at all as well. I believe because I am including the file name in the path the script is selecting the thumbnail.

What would be the best scripting method to select a thumbnail in bridge? Or is it better just to refer to the specific thumbnail itself to process it. If so, what's the best method for that?

Sorry for the questions, but I find Bridge scripting to be rather shadowy when compared to indesign or Photoshop. My preference would be to use this script with photoshop instead of bridge, but that is not an option that I have.

Thanks for any help you can offer.

Paul Riggott
Inspiring
January 14, 2011

You can select all the the thumbnails IE:


var script ='';
var newPath = "/c/pictures";
script +="app.document.thumbnail =Folder('"+newPath+"').fsName;";
script += "var sels = app.document.visibleThumbnails;";
script += "alert(sels.length);";
var bt = new BridgeTalk();
  bt.target = "bridge";
  bt.body =script;
  bt.send(8);