Does anyone have any ideas on where to find additional examples of Bridge scripts to study? I've been looking over the AdobeLibrary scripts, but I'm looking for something a little more basic to get the principles behind it, and ideally ones that work with CS2 with CS3 installed on the same system!
The end result I need, is to be able to select files in Bridge, and send that array of files to Photoshop for processing somewhere along the line, but I don't know quite where to start at the moment. I've got it opening files directly from a path from Bridge, but not from the Bridge selections.
Any ideas greatly appreciated!
More examples of Bridge scripts?
More examples of Bridge scripts?
I have written a few scripts for bridge, but am by no means a expert at it. Here are a few examples to get you pointed in the right direction.
Here is how you work with the files that are selected in bridge:
Code: Select all var l = app.document.selections.length; // length of selected files
var i = 0; // counter
while(i < l){
var tn = app.document.selections;
var fl = Folder(tn.path); // create folderObj
fl.rename(tn.name.toUpperCase());
i++;
};
Now if you want to have Photoshop from bridge, you would need to use BridgeTalk (bridges method of communicating with other adobe apps). I have never fully wrapped my head around the ins and outs of it, but here is an example of it I tried awhile back that works (i think):
Code: Select all // if photoshop is not currently running, launch it
if ( BridgeTalk.isRunning("photoshop") == false ) {
BridgeTalk.launch("photoshop", "background");
};
var image = app.document.selections[0].path;
var bt = new BridgeTalk; // create new BridgeTalk message object
bt.target = "photoshop"; // send this message to Photoshop
// the script to send to photoshop
bt.body = "var file = new File('" + image + "');" +
"var docRef = open(file);" +
"var myx = docRef.width.toString();" +
"var myy = docRef.height.toString();" +
"var md = {x:myx, y:myy};\r" +
"md.toSource();";
//For the result, use eval to reconstruct the object
bt.onResult = function(resObj) {
BridgeTalk.bringToFront("bridge");
md = bt.result = eval(resObj.body);
// Now you can access fname and fsize properties
alert(md.x + " / " + md.y);
};
bt.send(); // send the message
Hope this helps, let me know if you would like me to send over some of my scripts in their entirety.
Patrick
Here is how you work with the files that are selected in bridge:
Code: Select all var l = app.document.selections.length; // length of selected files
var i = 0; // counter
while(i < l){
var tn = app.document.selections;
var fl = Folder(tn.path); // create folderObj
fl.rename(tn.name.toUpperCase());
i++;
};
Now if you want to have Photoshop from bridge, you would need to use BridgeTalk (bridges method of communicating with other adobe apps). I have never fully wrapped my head around the ins and outs of it, but here is an example of it I tried awhile back that works (i think):
Code: Select all // if photoshop is not currently running, launch it
if ( BridgeTalk.isRunning("photoshop") == false ) {
BridgeTalk.launch("photoshop", "background");
};
var image = app.document.selections[0].path;
var bt = new BridgeTalk; // create new BridgeTalk message object
bt.target = "photoshop"; // send this message to Photoshop
// the script to send to photoshop
bt.body = "var file = new File('" + image + "');" +
"var docRef = open(file);" +
"var myx = docRef.width.toString();" +
"var myy = docRef.height.toString();" +
"var md = {x:myx, y:myy};\r" +
"md.toSource();";
//For the result, use eval to reconstruct the object
bt.onResult = function(resObj) {
BridgeTalk.bringToFront("bridge");
md = bt.result = eval(resObj.body);
// Now you can access fname and fsize properties
alert(md.x + " / " + md.y);
};
bt.send(); // send the message
Hope this helps, let me know if you would like me to send over some of my scripts in their entirety.
Patrick
More examples of Bridge scripts?
Thanks Patrick, I'll take a better look over that when I'm fresh in the morning.
Any scripts would be very gratefully received - I learn much better pulling other people's scripts apart and figuring out why they work than I do by sitting down with a book.
Any scripts would be very gratefully received - I learn much better pulling other people's scripts apart and figuring out why they work than I do by sitting down with a book.
More examples of Bridge scripts?
Hi Victoria
I will be updating my Bridge routines to cope with the possibility of CS3 tomorrow. I will then release my revised Bridge Launch script and my revised Photoshop Launch script. These will give you working examples. But they will also provide a means to avoid needing to set up batching routines within your individual scripts, since they provide a full built in batching capability, including using Bridge to point at files and folders, plus filters / selectors, multiple save options etc. The batch can then be run across any combination of (your) scripts or actions you care to select.
Andrew
I will be updating my Bridge routines to cope with the possibility of CS3 tomorrow. I will then release my revised Bridge Launch script and my revised Photoshop Launch script. These will give you working examples. But they will also provide a means to avoid needing to set up batching routines within your individual scripts, since they provide a full built in batching capability, including using Bridge to point at files and folders, plus filters / selectors, multiple save options etc. The batch can then be run across any combination of (your) scripts or actions you care to select.
Andrew
More examples of Bridge scripts?
Thanks guys. Sorry for the delay in replying, I've had a slightly manic few days with work reopening, but I think I'm back to scripting again now!