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

Export all open files to jpeg = bug?

Guest
Feb 09, 2010 Feb 09, 2010

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.name +".jpg");
           
                // Export to flash
                app.documents.exportFile(targetFile, ExportType.JPEG, options);
                app.documents.close();
            }
            alert( 'Documents exported as JPG' );
        }
    }
    else{
        throw new Error('There are no document open!');
    }
}
catch(e) {
    alert( e.message, "Script Alert", true);
}

TOPICS
Scripting
1.7K
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 1 Correct answer

Guru , Feb 09, 2010 Feb 09, 2010

Changing your 'for' loop to a 'while' loop and working with 'activeDocument' rather than documents 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();

           

...
Translate
Adobe
Guru ,
Feb 09, 2010 Feb 09, 2010

Changing your 'for' loop to a 'while' loop and working with 'activeDocument' rather than documents 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);

}

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
Guest
Feb 16, 2010 Feb 16, 2010
LATEST

Muppet Mark, you are a life saver! works like a charm!

Thanks!!

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