11 Replies Latest reply: Jun 4, 2012 8:35 AM by Muppet Mark RSS

    Help, Need to change ExportType

    RichardM0701 Community Member

      Hi,

       

      I have a handy script that exports my files to .png files. I need to change my script to export text files but I cannot find the appropriate ExportType for a .txt file. Can anyone help? See script below. Thank you very much in advance!!!

       

       

      var j, sourceDoc, targetFile;

       

      var destFolder = null;

      // Get the destination to save the files

      destFolder = Folder.selectDialog( 'Select the folder where you want to save the exported files.', '~' );

       

      if (destFolder != null) {

        for ( j = 0; j < app.documents.length; j++ ) {

          sourceDoc = app.documents[ j ]; // returns the document object

       

          targetFile = getNewName(sourceDoc, destFolder);

       

          // set PNG export options

          var opt = new ExportOptionsPNG24();

          opt.antiAliasing = true;

          opt.transparency = true;

       

          // Export

          sourceDoc.exportFile(targetFile, ExportType.PNG24, opt);

        }

        alert( 'Files are saved as PNG24 in ' + destFolder );

      }

       

      function getNewName(sourceDoc, destFolder) {

        var docName = sourceDoc.name;

        var ext = '.png'; // new extension for png file

        var newName = "";

       

        // if name has no dot (and hence no extension,

        // just append the extension

        if (docName.indexOf('.') < 0) {

          newName = docName + ext;

        } else {

          var dot = docName.lastIndexOf('.');

          newName += docName.substring(0, dot);

          newName += ext;

        }

       

        // Create a file object to save the png

        saveInFile = new File( destFolder + '/' + newName );

        return saveInFile;

      }