Export all open files to jpeg = bug?

hi there!
I'm currently writing a script that exports all the open documents to a JPEG.
this works except for one little thingy:
instead of exporting all the documents, it exports only the active one, with all the other document names...
so for example:
3 files opened, 3 files exported with a different, correct filename, BUT every jpeg shows the active file.
I don't know what I'm doing wrong, so if someone could jump in = AWESOME!
TY!
M.
this is my code:
try {
    if (app.documents.length > 0 ) {
        // Get the folder to save the files into
        var destFolder = null;
        destFolder = Folder.selectDialog( 'Select folder for JPG files.', '~' );
        if (destFolder != null) {
            var options, i;
            // Get the Flash export options to be used.
            var options = new ExportOptionsJPEG();
            // You can tune these by changing the code in the getOptions() function.
            for ( i = app.documents.length-1; i >=0 ; i-- ) {
                // Get the file to export the document as swf intos
                var targetFile = new File( destFolder + '/' + app.documents[i].name +".jpg");
                // Export to flash
                app.documents[i].exportFile(targetFile, ExportType.JPEG, options);
                app.documents[i].close();
            alert( 'Documents exported as JPG' );
    else{
        throw new Error('There are no document open!');
catch(e) {
    alert( e.message, "Script Alert", true);

Changing your 'for' loop to a 'while' loop and working with 'activeDocument' rather than documents[i] works fine for me…
Like so…
try {
    if (app.documents.length > 0 ) {
        // Get the folder to save the files into
        var destFolder = null;
        destFolder = Folder.selectDialog( 'Select folder for JPG files.', '~' );
        if (destFolder != null) {
            var options, i;
            // Get the Flash export options to be used.
            var options = new ExportOptionsJPEG();
            // You can tune these by changing the code in the getOptions() function.
            while (app.documents.length > 0) {
                // Get the file to export the document as swf intos
                var targetFile = new File( destFolder + '/' + app.activeDocument.name +".jpg");
                // Export to flash
                app.activeDocument.exportFile(targetFile, ExportType.JPEG, options);
                app.activeDocument.close();
            alert( 'Documents exported as JPG' );
    else{
        throw new Error('There are no document open!');
catch(e) {
    alert( e.message, "Script Alert", true);

Similar Messages

  • Save all Open Files in CS4?

    Hi all,
    Looking for a script that will save all open files as a a JPG to a specific directory.  I tried using this in CS4 but it doesnt work.  It just opens the save dialog and thats it.  Want something a bit more automated:
    var tempFolder = new Folder ("C:/Your_Temporary_Folder")
    tempFolder.create();
    var DL = documents.length;
    for(a=1;a<=DL;a++){
       activeDocument = documents[a-1];
       var AD=activeDocument;
       var imgName= AD.name;
       imgName = imgName.substr(0, imgName.length -4);
       AD.flatten();
       saveFile = new File("C:/Your_Temporary_Folder/"+imgName+".jpg");
       saveOptions = new JPEGSaveOptions();
       saveOptions.embedColorProfile = true;
       saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
       saveOptions.matte = MatteType.NONE;
       saveOptions.quality = 12;
       AD.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);
    Thanks.

    Hi guys,
    That fixed it.  The other problem was that the name length was too short:
       imgName = imgName.substr(0, imgName.length -0);
    So I corrected that as well.  Thanks for your help.
    Is it possible to add a "close without prompting to save" in the script?  So it basically saves the file then closes the window in PS without prompting me to save it again?

  • Export a raw file to jpeg losses lens information

    When I export a raw file to jpeg it losses the lens information.

    Ernie,
    I have never paid attention to those tags on exported JPGs before, but I have recreated the scenario you described.  I have a Canon XTi, and my CR2 master files have about 12 more EXIF tags than the JPG versions.  Excluded in the JPG is the lens model. 
    However, the lens information for my camera is Canon proprietary tags.  That is, the general EXIF lens tags are not populated by my camera, so I would not expect them to be translated to regular EXIF tags by Aperture in a JPG.  I.e., I don't think Aperture will take metadata from one proprietary tag and put it in the place of another standard tag.  I suspect that is the same is true in your case.
    nathan

  • Save all open files?

    Is there a way or a script to save all open files in Adobe Illustrator?
    Thanks

    Thanks. How would one edit this, especially so that it doesn't close the files?
    Do I just delete the 4th line from the bottom?
    var WR="WR-SaveAndCloseAll v0.2\n\n";
    if (language == "de") {
      var MSG_nodocs = WR+"Kein Dokument ge\xF6ffnet.";
      var MSG_ask = WR+"Sollen alle Dokumente gespeichert und geschlossen werden?";
    } else {
      var MSG_nodocs = WR+"You have no open document."
      var MSG_ask = WR+"Are you sure to save and close all open documents?";
    var itemstoprocess=0;
    var error=0;
    var Docs=documents.length;
    if (Docs<1) {
      error++;
      alert(MSG_nodocs);
    } else {
      if(confirm(MSG_ask)) {
        for(var i=0;i<Docs;i++) {
          activeDocument.close(SaveOptions.SAVECHANGES);

  • Close ALL open files and save jpg with jpg option

    Hi,
    I have some (a lot) of -jpg images to crop, and resize, while I have to do this one by one based on what portion of the image to crop, once done I need to close, and save them.
    To speed up the process I open several files, and do the crop&resize, and when finished I use "close all", and would like to avoid to confirm the "save" dialogue, and the "jpeg options" "image quality option" dialogue, having to say save, and the option set to a given value.
    Unfortunatelly I am not a coder, and didn't understand anything from the Javascript Scripting Reference guide.
    I found this
    app.docRef.close(SaveOptions.SAVECHANGES);
    here, I pasted it into ExtendScript, saved it, but when opening the script from file > scripts > browse it returns error 21 (undefined is not an object)
    Will you please kindly give me the script?
    Thank you

    Add this snippet to a script file.
    Load script file in PS scripts folder
    Restart photoshop
    Assign keyboard shortcut to script
    #target photoshop
    //Make Photoshop the formost Appplication
    app.bringToFront();
    // Requires at least one open document
    while (app.documents.length > 0)
         //Save all open windows
        {activeDocument.close(SaveOptions.SAVECHANGES);}

  • Lightroom 4 won't export all my files and doesn't notify which ones it didn't

    I have a large library and one day i wanted to make sure that none of the files were corupt so I thought of an idea to export my entire library to see if i get a notification if any of my files didn't export. I could then check on those files to see whats wrong. But trying to export that many images caused lightroom to crash so I exported by year instead. Some years were fine, but others like 2011 for example, out of 13906 images, only 9824 exported. I would be ok with that if lightroom notified me which images didn't export. Normaly, when i try to export images that are ofline, lightroom will tell me which ones didn't export and say that they can't be found. How am i supposed to find those 4000 images that didnt export if i don't know what there file names are? I tried exporting the previews as a catalog and all 13906 exported fine. I updated my dng previews and I even genereated new standard sized previews as well. I also ckecked for missing images under Library/Find Missing Photos, and there were none missing. Here are the type of files i was trying to export: DNG: 13017, jpeg: 9, PSD: 61, TIFF: 819. None were videos.
    Please Help!

    Thanks for your reply. I don't necesarily think I have corrupt files, but i want o make sure i don't so that when i do a back up, the corupt file doesn't replace the good ones on my backup drive. I have over 100,000 images in my library and there is absolutely no way that i am going to scroll through all of those to look for an exclamation point. I wish lightroom could scan my whole library for any questionalable files.
    I have tried to export known corrupt files where I could see an exclamation point or a large purples band, or both, and they don't export. Thats why i wanted to export my whole library to see if i can find any of those. But lightroom notifies me when they cant export. I don't know why it doenst say anyting now. Im glad you mentioned about the stacking, i didn't know about that, however, i don't used stacking, so that is not the issue. There might be 10 or 20 that i accidentally stacked, but not 4000.

  • Export all open docs as PDF

    I am working on a script which should export all the open docs as PDF.
    I use the following script to export. but InDesign does not export all the PDF. Assume, I have opened seven docs and the script exports only 4 docs and again come back to the first exported doc. can any one help how to resolve the issue.
    var myTotalDocs = (app.documents.length);
        for(var i = 0; i < myTotalDocs; i++)
            myDocument = app.documents[i];
            app.activeDocument = myDocument;
            var myFilePath = app.activeDocument.filePath;
           app.activeDocument.exportFile(ExportFormat.pdfType, File(myFilePath+"/"+".pdf"),false);
    Thanks

    Dear Ramji
    Please use the below code for solving your problem:
    //===================== Start : Export =================================//
    var myTotalDocs = (app.documents.length);
        for(var i = 0; i < myTotalDocs; i++)
            myDocument = app.documents[i];
            app.activeDocument = myDocument;
            var myFilePath = app.activeDocument.filePath;
           app.activeDocument.exportFile(ExportFormat.pdfType, File(myFilePath+"/"+".pdf"),false);
        myDocument.close(SaveOptions.NO);
    //===================== End: Export =================================//
    Once Export the InDesign open document then immediatly close... otherwise this problem [what you menditoned] will occure.
    Thanks & Regards
    T.R.Harihara SudhaN

  • Exporting All Audio Files - Having Some Problems. . .

    Hi,
    Im trying to export all my audio and audio intrument files as audio files so that i can pass them over to someone for a remix. Im having a couple of problems:
    1. Automation does not bounce with the tracks
    2. The tracks that run though busses does not bounce
    3. Some of the exported files appear as clipping when we look at the waveform. The levels in logic appear as normal but the waveform is full, both when we view the region on the arrange and in the sample editor.
    Has anyone got any advice on exporting all tracks as audio files or any advice on what this problem could be?
    Thanks, Ben

    benjamingordon wrote:
    Whats PDC. Might seem like a silly question but im a bit lost.
    Plug-in Delay Compensation. It's in the audio preferences, General tab.
    If i want to have automation, then i have to bounce each track individually?
    Yes. As John stated, the export feature bounces the file at Unity gain, and ignores automation. Generally speaking, this is the preferred method for handing off files to a mix engineer. But there are times when the automation is part of the sound you want. In these instances, you'll need to bounce those files, not export them. But certainly automation isn't part of every track?
    I would suggest soloing each Aux track, or audio/innstrument track that needs to be bounced WITH automation, and then bounce offline. Bouncing offline will speed up the process of having to do these tracks one at a time.
    When you're done with the bounced tracks, delete them from your arrange page (but DON'T hit SAVE). Then, use the function "Export ALL tracks as audio files", and all your remaining tracks will export at one time.

  • Can I run an action on all open files?

    I'm converting some of my images to grayscale with an action. The images are spread across hundreds of folders and only some of the images need to be converted. I want to be able to look at the image to make sure it should be converted (or not, as the case may be). So I end up with, for a particular folder, maybe 20 open images.
    Then I run the action manually on each image that is still open.
    QUES: Is there a way to select "run action on all open images".
    I know I could do it in Batch by moving all the files to a new folder, but every time I try to re-learn how to batch (I only resort to batch every year or two), an hour later I'm still reading the Help manual and nothing has been accomplished. So, an action it has to be, or manually.

    Might be quicker to set the action to a hot key, open all files in the folder and then inspect them and if they need the action, hit the key, otherwise ctrl-w to close unchanged.

  • Photoshop enlarges all open files when I magnify a file. How can i get it to only magnify one file

    When I use the magnifying glass to enlarge my file in photoshop cs3, all of my open files magnify at the same time. I only want one of them to enlarge. This started happening when I bought a new Macbook pro and installed OSX10.6.5. Does anyone know how I can fix it so only the file I am working on enlarges? sometimes I want to compare a smaller file to a larger file and I can no longer do that in Photoshop.

    Hello Gtarka,
      There is an option on the Zoom tool to "Zoom All Windows". This is just a check mark in the tool options bar, next to the "Resize Windows To Fit" option, directly under the Menu bar. Simply deselect this option.
      Please, in the future, post such questions here:
    http://forums.adobe.com/community/photoshop/photoshop_macintosh
      This forum is for questions about Photoshop.com, the web site.
    -Brett

  • When I export my RAW files to JPEG they're about half the size, is that right?

    So, I've been using Aperture for about 2-3 years.  I always shoot in RAW and then export to JPEG onto my desktop so I'm able to burn a disk.  In the past my JPEG size is about 2/3 the size of my RAW files. Now, it's about 1/2.  (ie, 23.72 MB in RAW is about 12.3 MB in JPEG) I'm not understanding why.  All my presets are to keep the original size.  I want my friends to have the full file size so they can go and get their own prints done...
    Thanks so much for anyone's help!
    Misty

    Misty,
    Lots of unknowns.  Is it the same camera shooting the RAW.  Is the RAW in both cases set the same -- with some it can be either lossless compressed or totally uncompressed RAW?  Also bit depth can be set differently with some -- what type of camera are you shooting?
    Is the JPEG compression set to 12 in both cases (size of 12.3 MB would likely indicate 12)?
    Ernie

  • Elements 12 organiser has changed all raw files to jpeg - how do I get raw files back?

    Cannot edit raw files as Elements (12) seems to have changed them all to jpegs - can anyone let me know how to get raw files back?

    Hello Jim,
    Many thanks for your response.  Wondering if we did something in Elements preferences?  Usually, when thumbnails are opened in the editor, it’s a raw file to work on.  However, all the thumbnails, when opened in the editor, are all of a sudden opening as jpegs …. not raw.  o it looks as though all the raw files are now jpegs, and we don’t know how to get them back.
    Any help you can offer will be gratefully received, as my husband works on his photos in Elements and it’s driven him mad!
    Many thanks & regards.
    Kim

  • How to save all open files IE like a shortcut or alias to them.

    Hi everyone,
    I know there must be a way to do this in Dreamweaver, but I
    can't find it.
    When I am working on a series of pages (for example, 3 or 4
    pages with a bunch of include pages) and I want to save a shortcut
    or alias that would re-open them all for me (like the "Bookmark All
    Tabs" option in Firefox that will save all the open tabs so you can
    open them all at once later).
    This will save a TON of time, instead of me writing down
    every single page name, and then, opening them all by hand later.
    I know you can use the Site Navigation, to see the files, but
    that runs sooooo slooooowwwww.
    I appreciate the help in advance,
    Regards,
    Don

    yeah, i can definitely see how it would be useful for some
    people! and
    hey, for all i know, i'm the one who's not an average user. i
    was
    pretty much just saying that i can see how that's something
    Firefox
    would think to do, but not necessarily a program like
    Dreamweaver. but i
    agree that it would be a useful feature in lots of programs.
    and i think
    that what Murray suggested is probably pretty close to what
    you're
    looking for, if not exactly.
    d_macman wrote:
    > To respond to both...
    >
    > courtney (n h c)... I must not be the average user then.
    We have many sites,
    > and I do a LOT of development, and many times, I may
    have several pages with
    > several includes on a page. IE, for a form page, I may
    have 10-12 pages total
    > (including headers, footers, java, PHP process pages,
    etc) and to work out the
    > processes and for development, I may create several
    versions depending on the
    > problems I run into.So to not go nuts, I would LOVE to
    save the batch of pages
    > out, and then be able to re-open them all at once.
    Making it easy to jump in an
    > out of a test section (I have them saved in a site, and
    dont want to make
    > second sites just for this purpose).
    >
    > Not to mention, leaving work and coming back in and
    finding out the power went
    > out over the weekend and my machine shutdown (and yes, I
    have a UPS, but it
    > wont run the system for that long).
    >
    > So, you see why I would like to save them as batch, like
    Firefox, way easier.
    >
    > Murray *ACE* ...
    >
    > I will try that, I did not even know that was there. Way
    cool ! I hope it
    > works, especially for power outages, like I mentioned
    above!
    >
    > Thanks all,
    >
    > Don
    >
    >

  • Hey All, Commons file upload getname bug fix  gives errors

    Hey im trying to implement this bug fix i found in the forum, but i get errors at the (pos+1) line of code.
    here is an extract of my code
    if (fileItemTemp.getSize() > 0)
    out.println("its a file");
    File filename = new File(fileItemTemp.getName());
    int pos=(fileItemTemp.getName()).lastIndexOf("\\");
    if (pos!=-1)
    File filename=new File(fileItemTemp.getName()).substring(pos+1);
    else
    File filename=new File(fileItemTemp.getName());
    String temp = filename.getName();
    File saveTo = new File(newDir +"/"+ temp);
    fileItemTemp.write(saveTo);
    any help would be appreciated, thanks all, keep developing
    Mark

    I think u can find the solution from this site
    [http://fileuploadanddownload.blogspot.com/]
    or
    [http://fileuploadanddownload.blogspot.com/]

  • How do I stop lion from opening all previously opened files on restart?

    How do I stop lion from opening all previously opened files on restart?  I want to wipe all open files, since that seems to be the most efficient way to close lots & lots of open files (that build up over the course of normal activities)

    One way is to always quit all applications before you shut down.
    An easy way to do this (although in my own experience it doesn't seem to always work perfectly) is to simply hit CMD + TAB + Q and hold down all three keys. 
    When you do that the computer will cycle through all open apps and close them. If there are any open files that haven't been saved, it won't close them. So you should save everything you want to save before you hit CMD + TAB + Q. 

Maybe you are looking for