Scripting with bridge

Hello, i am pretty new to this so i am still figuring out how this scripting works
In general what i want to do is generate a jpg image from an symbols.ai library file and because bridge shows this library in some way, i want to use a script against bridge.
So now i have found a script from the sdk - SnpSaveAsJPEG and i am trying to understand what is happening because i have no experience with javascript.
maybe some advice on some good literature is also good?
can someone please help me with the following questions:
at the bottom we have "new SnpSaveAsJPEG().run();" that makes the program run
why is it executing the (at the top) "function SnpSaveAsJPEG()" even if you change that functions name?
why do we set requiredContext?
is the "$.level" always needed and why do we set it?
next we have the method "SnpSaveAsJPEG.prototype.run = function()"
where does "prototype" come from?
Why is it executing this function as there is nowhere a reference to this?
thanks

Hello Muppet Mark.
We are using CS 5.5
Here is the sample code, as found in the sdk(but some little test modifications by me), copyright adobe
The script is working correct, but i am trying to understand how it does what it does.
#target bridge
#targetengine "MainEngine"
function SnpSaveAsJPEG()
    //The context in which this snippet can run.
     //type String
    this.requiredContext = "\tExecute against Bridge.\nBridge must be running and \n"
        + "at least one thumbnail selected that is not a folder.";
    $.level = 1; // Debugging level
Functional part of this snippet. 
Gets a File object for each selected thumbnail, and uses it to
create a BitmapData object. Uses the BitmapData object to export
to the JPEG format.
     @return True if the snippet ran as expected, false if no files are selected in Bridge
     @type Boolean
SnpSaveAsJPEG.prototype.run = function()
    var retval = true;
    if(!this.canRun()) {
        retval = false;   
        return retval;
    // Get the selected Thumbnail objects - only accept these file types
    var thumbs = app.document.getSelection("ai");
    // Go through each of the selected thumbnails
    if(thumbs.length != 0)
        for(var i = 0;i < thumbs.length;i++)
            // get associated File object, ignore folders
            if(thumbs[i].spec instanceof File)
                var thumb = thumbs[i];
                // create a BitmapData object
                var bm = new BitmapData(thumbs[i].spec);
                if(bm instanceof BitmapData)
                    // create the path and file name
                    var exportFilePath = thumbs[i].parent.spec + "/SnpSaveAsJPEG_" + thumbs[i].name + ".jpg";
                    // create the new file and export the data
                    bm.exportTo(new File(exportFilePath));
    else
        retval = false;
    return retval;
Determines whether snippet can be run given current context.  The snippet will
fail if these preconditions are not met:
<ul>
<li> Must in Bridge
<li> At least one file must be selected in Bridge
</ul>
@return True if this snippet can run, false otherwise
@type boolean
SnpSaveAsJPEG.prototype.canRun = function()
    // must run in Bridge
    // must be at least one selection.
    if((BridgeTalk.appName == "bridge") && (app.document.selectionLength > 0))
        return true;
    // Fail if these preconditions are not met. 
    $.writeln("ERROR:: Cannot run SnpSaveAsJPEG");
    $.writeln(this.requiredContext);
    return false;
"main program": construct an anonymous instance and run it
  as long as we are not unit-testing this snippet.
//if(typeof(SnpSaveAsJPEG_unitTest)  == "undefined") {
//    new SnpSaveAsJPEG().run();
new SnpSaveAsJPEG().run();

Similar Messages

  • Copy GPS Metadata Back into Photoshop TIFFs with Bridge Scripting

    I've published a sample script on the Bridge blog about metadata scripting with Bridge and AdobeXMPScript -- specifically the script deals with GPS metadata and automation that synchronizes work done by both Bridge and Photoshop.
    Here is the link:
    http://blogs.adobe.com/bridge/2009/01/copy_gps_metada_1.html
    Enjoy!
    -David

    I couldn't read all through your post as I am jetting out of here.
    Buy this:
    http://www.fastpictureviewer.com/codecs/
    and install it. It's relatively cheap. Screen shot is from Windows Explorer.
    Handles ID, PSD, etc., files as well. Though the preview uses greeked text for the most part for the ID files.
    Take care, Mike

  • Memory Error in Bridge while running a script with multiple moveTo()'s.

    I have written a script to create folders based on the names of assets in the parent folder, then move the assets with matching names into the appropriate folders. The script runs perfectly up to somewhere between 1,000 to 1,500 images moved and then I receive a memory error from Bridge.
    I have been running this on folders with an excess of 25,000 assets in them. My work around was to put a simple counter in the script to let me know when 1,000 assets had been moved, throw up an alert, and then I would view the Task Manager to let me know when the CPU usage had dropped below 50% and would ok the alert, then it would run the next 1000 assets.
    My question, is it possible in scripting to monitor your memory usage to allow a pause in the script so Bridge processing can catch up?

    Don't do that!
    $.sleep() doesn't "sleep". ExtendScript is not multi-threaded. $.sleep just waits on the $.sleep() command to execute. It actually blocks all processing rather than free up the processor to do things like garbage collection.
    First try the $.gc() command. To my knowledge there is no way to track ES' memory usage.
    If that doesn't work, try scheduling a task...
    Let's say that you find that after 1000 moves, it takes 60 seconds for the processor to cool off:
    doAThousandMoves = function() {
    // execute 1000 moves
    app.scheduleTask( "doAThousandMoves()", 60000, true );
    The way I would actually code this is to scan the folder tree and create a global array that contained all of the files to be moved.
    I would then move them 1 at a time, shifting them off the array. Something like this:
    var mover = {}; // global object declaration
    mover.init = function() {
    mover.files = new Array();
    // fill mover files with the file objects to be moved.
    app.scheduleTask( "mover.move()", 10 );
    mover.move = function() {
    var i = 0;
    while ( i++ < 1000 ) {
    file = mover.files.shift();
    // move file
    if ( mover.files.length > 0 ) {
    app.scheduleTask( "mover.move()", 60000 );
    In fact, you should probably break this into chunks of about 10 or so at a time (you can reduce the gap between calls). Doing so will make the operation appear to be running as a background process.
    Regards
    Bob

  • Help Getting Started with Bridge Scripting

    I'm trying to learn enough about scripting to understand/modify some simple Bridge scripts, but can't seem to find the proper documentation. I have downloaded the Bridge SDK, have the documents for Adobe Intro to Scripting, Adobe Bridge CS5 javascript Guide and Javascript Reference Manual, and a general Javascript manual. But I can't find where BridgeTalk commands (such as send, onResult, and remote Photoshop calls) are described, as well as many other commands like push, localize, or the use of $ signs.
    Can anyone point me to reference materials I would need to learn these things??
    Many Thanks

    JavaScript Tools Guide CS5.pdf Should be in a folder along with the ESTK install… You will find most of you subject matter in that. Mine on the mac is located…
    /Applications/Utilities/Adobe Utilities - CS5/SDK/JavaScript Tools Guide CS5.pdf
    If not then get one from http://www.adobe.com/devnet/scripting.html

  • Can i with a script force bridge cs5 to show only raw files?

    Hi
    i know there is the filter feature
    but i have every time to set to show me the raw files
    can a script show only raw files ? like *.cr2
    in short i work only with raw files
    i would like to have a solution to display only raw files
    to load with bridge and have bridge ready to show only raw files
    set it on the filter feature is boring ,seeing i use it a lot and every time i run bridge i have to set the filter every time
    thanks

    It appears that with the Sort function set to Flie Type you can bring up just the raw
    files as a group.  With the Filter it appears that it always opens up in the default mode to arrange by file name.
    You could get a script to change it to file type, but that does not save any effort over just clicking on it in the Filter section.  Whether or not you can get a script to change the defalult I would ask in the Bridge scripting forum.  http://forums.adobe.com/community/bridge/bridge_scripting

  • Workflow issue with Bridge and everything else

    Short and sweet. Well, not really.
    I use windows - so as a result, for some reason unknown to man (after a decade of waiting), I still cannot see "previews" of most, if not all of any adobe software in the windows dialogue boxes.
    think PDF's and the registry hacks we have to do to "enable" previews. But on a mac I can?
    So I have to use bridge - a lot.
    Now when I have a linked image in illustrator (or whatever) and choose "reveal in bridge" it will hunt and drill down through a multitude of folders and display the image in it's native folder - which I can then open in photoshop for instance - edit it - and Illustrator will detect the change and update. Awesome.
    But aside from running a script to send a batch job to a program, it really doesn't "do" anything else that one would expect a "bridge" to do;
         I cannot create a "project" portfolio that would track a client project and all it's related documents.
         Or collaborate with a team.
         I cannot have non destructive edits of a document (such as using an instance of a file like lightroom does) - or "send copy to photoshop" and have Bridge stack the results.
         I cannot combine and tag collections of documents (make a database of stuff).
         I cannot ask Bridge to tell me which documents have placed documents, or (vice versa) which documents are placed into other documents - that would be so cool.
              imagine being able to select a jpeg or psd file and have the option to "Find documents using this file"
              or looking at a "project" and having a list of all first level documents with all their subsequent "placed content" listed all drop down expandable
    So my beef today is that I finally spent an hour messing about thinking I had something "wrong" and went through Bridge CS6 with a fine tooth comb trying to find out if anything had changed.
    and nope - it still doesn't behave as one would think it would.
    Currently, I have some documents that require monthly changes to images, which for the most part came from one photo shoot, and all have essentially the same perspective, appearance, lighting and shading, but all different products and I have a folder of "preformatted images". So monthly I really only need to update the images, and a bit of text. Being posters, InDesign whines a bit for vector art manipulation, so I stick to Illustrator for this job.
    But in Illustrator, I cannot choose another image to replace my linked image - without either;
         a: (reveal in bridge), select new replacement image - place as a new image, which then needs to be manipulated as the "old" image was, "remaking" all the adjustments, and then finally deleting the original linked image.
         b: (reveal in bridge) keep bridge open on the image I need (and it's name), go back to illustrator to open the "relink" windows dialogue and "blindly" browse till I find the image I want as shown in bridge.
         c: simply relink and browse blindly to find a file you can't see a preview of and guess, or drag and drop, or all the other non practical ways to replace the image.
    Option B gives the desired end result where the image I have in a clipping mask, buried in a document in a certain way, with certain effects, is simply replaced without impacting anything else.
         But this takes quite some time when there are a lot of images.
    So Bridge and its promised workflow functionality still isn't living up to it's purpose exactly.
    Bridge isn't bridging.
    With indesign, it's the same issue - you can't "relink" by revealing in bridge, choosing a "replacement" image and "update"
    Maybe a "relink with Bridge" choice in the Links menu?
    and in bridge, since Illustrator triggered the request, a button appears to "Replace" - once you finish browsing and highlighting the replacement image you need, just click it and it's done.
    So two issues -
    Why can't previews of adobe files be shown in windows explorer (still)?
         if they did, I'd really have no use for Bridge.
    Why isn't bridge actually communicating with the apps connecting to it?
    - and yes, I understand that I cannot ask bridge to go find a placed file and replace it with "this" file, but when illustrator "asks" for "this", bridge should be able to "respond" and give "that" since the app initiated the request.
    Bridge should be a workflow tool as advertised - it should literally be able to be a proper workflow hub for all things adobe (and be able to catalogue and track all design file type previews - corel files, cad, 3d, etc)... but as it stands it's just a glorified windows explorer without workflow options.
    Bridge hasn't been altered in years, and it's still lingering around - I think - so that we can simply see thumbnails, rather than just allowing each adobe program to make "previews" windows needs.
    I can change metadata in windows, I can use freeware to change it extensively.
    So aside from the "open in" options and the ability to browse all adobe file types, what's the point?

    I couldn't read all through your post as I am jetting out of here.
    Buy this:
    http://www.fastpictureviewer.com/codecs/
    and install it. It's relatively cheap. Screen shot is from Windows Explorer.
    Handles ID, PSD, etc., files as well. Though the preview uses greeked text for the most part for the ID files.
    Take care, Mike

  • Run Photoshop script from Bridge

    Hi
    I have a modified version of Image Processor script in photoshop scripting folder (it saves RAW files as smart objects) and would like to run it from Bridge (apply to selected images). Right now I can run script from File > Scripts Photoshop menu but not in Bride Tools > Photoshop
    Thank you
    The help will be appreciated

    Its Not Adobe Code and its not shipped with Photoshop.  Photoshop versions also has bugs in ScriptUI which is used by scripts with a dialog.  Image Processor Pro 2.3.1 has some bugs. Some files formats its saves may have problems.
    Russell Brown works for Adobe but he has been pulled away from Photoshop.  Xbytor is the programmer that wrote Image Processor Pro he does not work for Adobe and he is feed up with Adobe for not fixing bugs in Photoshop scripting.  He stated he will support Image Processor Pro for some time.
    Russell web site has this. The Open Source code is now available for many of my script and panels
    Because of new projects and a changing demand for my time, it will be necessary for me to move on to new projects at Adobe. For this reason I will no longer be able to support, or update many of my scripts and panels. Never fear! – I am releasing the source code for many of my programs and if you are a programmer then you can use this code to modify and change my scripts to meet your needs. If you are not a programmer then I recommend working with anyone on the list of programmers that I have supplied below. However! Let me make it clear that his code is not to be sold. This is an open and free source to be used for the good of humankind and Adobe Photoshop users around the world
    ===========================
    I do not have a Mac or a Windows 8 machine to test on. On my Windows 7 PC Image Processor Pro 2.3.1 and newer versions run on CS6, CC and CC 2014..  X is still working on it

  • ScriptUI edittext scrollbar problem with Bridge CC Mac

    Hello,
    With Bridge CC for Mac, in the UI, the scrollbar which come with edittext and multiline option, is not active.
    The scrollbar on the right appears by typing text or ENTER, but not by scripting.
    Any idea? Thanks
    #target bridge
    var textgen = new Array();
    for (var r = 0; r < 15; r++) {
        textgen[r] = ("line "+r);
    var generatedtext = (textgen.join('\n')); 
    var win2 = new Window("dialog", undefined, [0,0,200,200], ); // UI
    with(win2){    
        win2.eText = add( "edittext", [5,45,140,175], generatedtext, {multiline: true, scrolling: true} ); // problem here with Bridge CC Mac
        win2.retour = add( "button", [150,5,195,32], "Close" );
    win2.retour.onClick = function() {win2.close();};
    win2.center();
    win2.show();

    Welcome to the wonderful world of bridge UI unsolved bugs!
    On Mac and PC bridge, CS6 or CC
    Sign the petition if we want to make some pressure on in here:
    http://gsfn.us/t/34ccy
    and here:
    http://gsfn.us/t/46vwa
    It time to say it:
    If (Bridge_Team.exists) {
         alert("Help on this old unsolved bug!")
    } else {
         alert("Cloud CC deserves our trust?");

  • Frustrating problem with Bridge 6.1.0

    I have been experiencing a frustrating problem with Bridge 6.1.0 and previous versions. Soemtimes when I save a file to a particular folder, the file is present in the Finder window, but is not visible in Bridge. If I move the file from Finder to Bridge by draging it there, then it shows up but it is so frustrating to have to do it this way. I have tried to use the «Refresh» function in Bridge but that does not help. All scripts are turned on in Preferences- I have Mac  OS X 10.9.4

    The current version will not run on Mac OS 10.6.8. Thanks for any assistance.
    The easiest way would be to update to at least 10.7.5 (supported on most older Macs) but maybe you have strong reasons not to do so, however it will put you in to more trouble in the future because newer applications have more often the habit of not being able to support older OS versions due to limitations of this old OS.
    Here is the announcement of Adobe:
    http://blogs.adobe.com/creativecloud/moving-ahead-with-mac-os-x-10-7-and-higher/
    However PS CC should still work on your system and otherwise CS6 should. As a cloud subscriber you still have access to both CC and CS6 on the Adobe CC download pages. But only PS is a major upgrade (changed to version 2014) and Bridge has just a minor update and should still work on 10.6.8 I would think?
    Installing the updates and upgrades did not remove or uninstall the CC versions of PS, otherwise use CC application to install CC again.

  • Will Photoshop CC work with Bridge CS6

    Hi
    I'm about to download Photoshop CC (Windows 7). I already have Photoshop CS6 and Bridge CS6 installed. My questions is do I have to download and install Bridge CC or will Photoshop CC work ok with Bridge CS6.
    Thanks

    Like versions communicate with each other with the statup scripts.  So CS6 Bridge is going to call CS6 PS when you select PS/Tools.  It has no communication link to CC. 
    You can open images in CC from CS6 but you will not be able to use Tools/photoshop to call up Bridge CC.

  • Add Startup scripts to Bridge

    hello
    I would like to do as above, with InDesign you have a fodler called Scripts/Startup Scripts with scripts inside can i do the same with Bridge CS6?
    Thanks

    There are 2 startup script folders with Bridge…
    One contains the Adobe Scripts that provide the built-in functions…
    Library/Application Support/Adobe/Startup Scripts CS5/
    Most likely the one you want though is the user one…
    You can reveal this if you go to the app preferences…

  • Adobe Creative Cloud/Photography: does it come with Bridge?

    Does anyone know if Adobe Creative Cloud/Photography comes with Bridge?

    Yes, it does.
    I've found that Adobe has put lots of effort into pushing Photoshop and Lightroom as part of that plan but does not fully explain the entire plan anywhere convenient.
    Think through how you'll use them: Should I use Lightroom or Bridge? | The Complete Picture with Julieanne Kost | Adobe TV
    Full list of inclusions here: Adobe Sets Permanent Plan Discount for Photoshop CC + Lightroom | ProDesignTools

  • Having problems with Bridge shutting down after saving photo in PS Cs5,,,,,,,,,  Also when i attempt to update either PS or bridge get an error message in Adobe application manger "Error loading updater workflow"

    Having problems with Bridge shutting down after saving photo in PS Cs5,,,,,,,,,  Also when i attempt to update either PS or bridge get an error message in Adobe application manger "Error loading updater workflow"

    Sorry for the late reply. My email firewall has become a little over zealous & sent a lot of my emails straight to my junk email folder, so I have only just now discovered your reply in my junk mail folder.
    The only "don't open files exceeding xxx megabytes" instruction I can find in my Prefs, is in the Bridge Prefs for Thumbnails, & mine is set at 1000mb. The biggest files I handle are bigger than 200mb so I should be able to open a few, not just one.
    However, this doesn't explain why I can open a psd format file of 180mb, close it, but then can't open a RAW format file of only 26mb immediately after.
    I can open the RAW file only if I restart my computer - very annoying!
    However, thanks for the advice about the video card & memory.
    So, I'm still stuck as to what the issue is.

  • Hi I have been having a problem with Bridge in CS4 recently. So uninstalled CS4 and Lightroom 4.4 and reinstalled them on my Desktop PC. When I turned on Bridge through CS4, My thumb nail images disappeared and a thumb nail icon with CR2 appeared. Now som

    Hi I have been having a problem with Bridge in CS4 recently. So uninstalled CS4 and Lightroom 4.4 and reinstalled them on my Desktop PC. When I turned on Bridge through CS4, My thumb nail images disappeared and a thumb nail icon with CR2 appeared. Now some of my images have disappeared from Light room 4.4, but I can find them in CS4 and Bridge now shows some thumb nails as images and some as an icon with CR2. I have spent two weeks going through preferences etc. to find how to resolve my problem. Please can you Help? Meany thanks in advance
      Derek Randall

    I don't use LR and rarely use the bridge so I can not answers about thumbnails in them,  However thumbnails in windows file explorer and windows dialog for CS2 files will only show if you have installed codec into windows that will produce them. Windows does not do CR2 thumbnails on its own. I use FastPictureViewer Codec package for RAW File and PSD files thunbmail support.

  • Which is better approach to manage sharepoint online - PowerShell Script with CSOM or Console Application with CSOM?

    Which is better approach to manage sharepoint online - PowerShell Script with CSOM or Console Application with CSOM?
    change in sharepoint scripts not require compilation but anything else?

    Yes, PowerShell is great, since you can quick change your code without compilation.
    SP admin can write ps scripts without specific tools like Visual Studio.
    With powershell you can use cmdlets,
    which could remove a lot of code, for example restarting a service.
    [custom.development]

Maybe you are looking for

  • How to use objects from other SWCs in my BPM Integration Scenario

    Dear all, I am experiencing some difficulties with the following. I have created a BPM Integration Scenario in a SWC. It contains a tranformation step in which a message from that SWC is split and mapped to two IDOCs. These IDOCs are imported in anot

  • Oracle 11g upgrade issues

    Hello : We recently migrated our database from 9.2.07 (RBO) to 11.2.0.1 (CBO) ( Solaris 10 Sparc 64 bit ). Ever since the migration happened we are experiencing the following issues: 1. Execution plans are very costly. ( Please note that we moved fro

  • When calling the slider are hidden

    Yesterday I made the new update for blackbery classic Now I have the problem that when you receive a call, the two slider (Green button - red button) are barely visible on the touchscreen and I still can not accept telephone calls. At the bottom edge

  • My xpreia not found in about phone software updates

    After buying this phone and spending ages setting it all up, I find that I can not activate the my xperia feature.  Sony website says go to settings/about phone/software updates to find options but nothing is there, just stating that phone is up to d

  • I have created a form but it won't let me 'save as PDF Form'

    Hi there, I have created a form but it won't let me 'save as PDF Form'. When I click the button a timer appears then disappears without creating the pdf form. I have created forms previously and not had this problem before. Thanks