/* * Description: An Adobe Photoshop script that converts multiple PDF files into the native PSD file format. * License: GNU General Public License Version 3. (http://www.gnu.org/licenses/gpl-3.0-standalone.html) * Copyright (c) 2012, Michel Simons * http://www.no-nonsens.nl * 1.06 November 4th 2018 * 1.05 March 11th 2012 * 1.04 February 21th 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ // // To Do => nothing.....? // // Known issues => progress dialog does not always update... unfixable (scriptUI limitation) // => open folder dialog does not remember last opened path... unfixable (scriptUI limitation) // ******************************************************************************************************** // ** ** // ** initialize variables and start dialog ** // ** ** // ******************************************************************************************************** #target photoshop if (app.name != "Adobe Photoshop") { alert ('This script is created for Adobe Photoshop CC, it is not developed for or tested on ' + app.name + '. Results can be unexpected.' ); } var ScriptVersion = "1.06"; var UseDebug = 0; var export_to_dialog_window; // make window global var fileList = new Array(); var msis_dialog_base_path = ""; // default output folder var msis_message_1 = "\nThis script converts multiple PDF or AI (PDF compatible) files into the native Photoshop PSD file format. Note that thin strokes may disappear when rasterizing with less than 300 pixels/inch resolution."; var msis_message_2 = "RasterizePDFFiles.jsx\n\n" + "All copyright (c) 2018 No-Nonsens inc. reserved.\n" + "written by Michel Simons / No-Nonsens inc.\n" + "http://www.no-nonsens.nl\n\n" + "released under GNU General Public License."; // run dialog screen export_to_file_dialog(); function Search_Array(ArrayObj, SearchFor){ var Found = false; for (var i = 0; i < ArrayObj.length; i++){ if (ArrayObj[i] == SearchFor){ return true; var Found = true; break; } else if ((i == (ArrayObj.length - 1)) && (!Found)){ if (ArrayObj[i] != SearchFor){ return false; } } } } function DebugAlerts(DebugMessage) { if (UseDebug == 1) { alert (DebugMessage ); } } // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************************************* // ******************************************************************************************************** // ** ** // ** building and showing main dialog ** // ** ** // ******************************************************************************************************** function export_to_file_dialog() { // Export dialog export_to_dialog_window = new Window('dialog', 'Convert multiple PDF files into the Photoshop PSD file format - v' + ScriptVersion); // PANEL with usage instructions export_to_dialog_window.MessagePanel = export_to_dialog_window.add('panel', undefined, 'Convert PDF files into Photoshop files'); // GROUP var Message_Group = export_to_dialog_window.MessagePanel.add('group', undefined, '') Message_Group.orientation = 'column'; Message_Group.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP] // Labels var Message_Group_label_1 = Message_Group.add('statictext', undefined, msis_message_1, {multiline:true}); Message_Group_label_1.size = [500,60]; // PANEL with file stack export_to_dialog_window.PrefixPanel = export_to_dialog_window.add ('panel', undefined, 'PDF files for conversion:'); // GROUP export_to_dialog_window.PrefixPanel.orientation = 'row'; export_to_dialog_window.PrefixPanel.alignChildren = "top"; var File_Stack_Group = export_to_dialog_window.PrefixPanel.add('group') File_Stack_Group.orientation = 'column'; export_to_dialog_window.StackFileList = File_Stack_Group.add ("listbox",undefined,[],{multiselect: true}); export_to_dialog_window.StackFileList.preferredSize = [405,120]; // // Add Files Button // var myButtonGroup = export_to_dialog_window.PrefixPanel.add ("group"); myButtonGroup.orientation = 'column'; myButtonGroup.size = [90,120]; var FileStackAddButton = myButtonGroup.add('button', [10,85,100,105], 'Add ...' ); FileStackAddButton.onClick = function() { try { if (fileList.length != 0) { var AlreadyAddedFiles = fileList; var NewlyAddedFiles = File.openDialog("Select files to batch","Acrobat PDF files:*.pdf,Illustrator AI files:*.ai,All files:*.*" ,true); if (NewlyAddedFiles != null) {fileList = AlreadyAddedFiles.concat(NewlyAddedFiles);} // only do this if cancel has not been pressed } else { var NewlyAddedFiles = File.openDialog("Select files to batch", "Acrobat PDF files:*.pdf,Illustrator AI files:*.ai,All files:*.*" ,true); if (NewlyAddedFiles != null) {fileList = NewlyAddedFiles;} // only do this if cancel has not been pressed } if (NewlyAddedFiles == null) // null cause pressed cancel (somehow cancel destroys the array?) { return; // user pressed cancel on file opendialog so return to main dialog } // Files are added to the fileList array, now also add also the filenames to the listbox // As fileList can contain old and new we first have to empty the listbox export_to_dialog_window.StackFileList.removeAll(); // and then refill again for (var i in fileList) { if (fileList[i] instanceof File && fileList[i].hidden == false) { // strip file path var FullPathFileName = fileList[i]; var FullPathFileAsString = FullPathFileName.fsName; var StrippedPathFileName = FullPathFileAsString.replace(/^.*[\\\/]/, ''); export_to_dialog_window.StackFileList.add ("item",StrippedPathFileName); } } // now update the save folder location to the last added files location, also update var that keeps save location msis_dialog_base_path = FullPathFileName.parent; ExportEdit.text = msis_dialog_base_path.fsName; //ExportEdit.text = export_to_dialog_window.ProgressLabel.text = fileList.length + ' files are waiting for conversion.'; } catch(err) { alert( err ); } } // function end; // // Remove Files Button // var FileStackRemoveButton = myButtonGroup.add('button', [10,85,100,105], 'Remove ...' ); FileStackRemoveButton.onClick = function() { if (fileList.length != 0) // check if there are files in the array { try { // add selected items in array var SelectedItemsArray = export_to_dialog_window.StackFileList.selection; // check if the array exist (did user make a selection of files to remove) if (SelectedItemsArray != null) { // walk through listbox for (r=0; r < SelectedItemsArray.length; r++) { // find selected item and store corresponding list number var ThisItem = export_to_dialog_window.StackFileList.find ( SelectedItemsArray[r] ); // remove item from listbox ThisNumber = Number ( ThisItem.index ); export_to_dialog_window.StackFileList.remove( ThisItem ); // and remove item from array fileList.splice( (ThisNumber) ,1 ); } } // array contains items } // try catch(err) { alert( err ); } export_to_dialog_window.ProgressLabel.text = fileList.length + ' files are waiting for conversion.'; } // list contains items } // function end // // Clear Files Button // var FileStackClearButton = myButtonGroup.add('button', [10,85,100,105], 'Clear ...' ); FileStackClearButton.onClick = function() { try { // clean listbox dialog export_to_dialog_window.StackFileList.removeAll(); // and also clean fileList array fileList.length = 0; } catch(err) { alert( err ); } export_to_dialog_window.ProgressLabel.text = fileList.length + ' files are waiting for conversion.'; } // PANEL with file stack // PANEL with Import Options export_to_dialog_window.OptionsPanel = export_to_dialog_window.add ('panel', undefined, 'PDF rasterize options:'); // GROUP Options_Group2 = export_to_dialog_window.OptionsPanel.add('group', undefined, '') Options_Group2.alignChildren = "left"; Options_Group2.size = [500,35]; Options_Group2.orientation = 'row'; export_to_dialog_window.myTrimCropSettings = Options_Group2.add ("dropdownlist", [10,85,90,105], ["Bounding Box", "Media Box", "Crop Box", "Bleed Box", "Trim Box", "Art Box"]); export_to_dialog_window.myTrimCropSettings.selection = 4; // start with 0 export_to_dialog_window.myDPISettings = Options_Group2.add ("dropdownlist", [10,85,130,105], ["72 pixels/inch", "100 pixels/inch", "150 pixels/inch", "200 pixels/inch", "300 pixels/inch", "600 pixels/inch", "1200 pixels/inch", "2400 pixels/inch", "4800 pixels/inch"]); export_to_dialog_window.myDPISettings.selection = 4; // start with 0 export_to_dialog_window.myColorSettings = Options_Group2.add ("dropdownlist", [10,85,100,105], ["Grayscale","RGB Color", "CMYK Color", "Lab Color"]); export_to_dialog_window.myColorSettings.selection = 2; // start with 0 export_to_dialog_window.myBitsSettings = Options_Group2.add ("dropdownlist", [10,85,80,105], ["8 bits","16 bits","32 bits"]); export_to_dialog_window.myBitsSettings.selection = 0; // start with 0 export_to_dialog_window.myAntiAliasedSettings = Options_Group2.add ("checkbox", undefined, "Anti-aliased"); export_to_dialog_window.myAntiAliasedSettings.value = true; // PANEL with Up / Downsample Options export_to_dialog_window.UpDownPanel = export_to_dialog_window.add ('panel', undefined, 'Photoshop up/downsampling options:'); // GROUP Options_Group3 = export_to_dialog_window.UpDownPanel.add('group', undefined, '') Options_Group3.alignChildren = "left"; Options_Group3.size = [500,35]; Options_Group3.orientation = 'row'; export_to_dialog_window.UpDownSampleSettings = Options_Group3.add ("checkbox", undefined, "Resample image"); export_to_dialog_window.UpDownSampleSettings.value = false; export_to_dialog_window.UpDownDPISettings = Options_Group3.add ("dropdownlist", undefined, ["72 pixels/inch", "100 pixels/inch", "150 pixels/inch", "200 pixels/inch", "300 pixels/inch", "600 pixels/inch", "1200 pixels/inch", "2400 pixels/inch", "4800 pixels/inch"]); export_to_dialog_window.UpDownDPISettings.selection = 3; // start with 0 export_to_dialog_window.ResampleSettings = Options_Group3.add ("dropdownlist", undefined, ["Nearest Neighbor (preserve hard edges)","Bilinear", "Bicubic (best for smooth gradients)", "Bicubic Smoother (best for enlargement)", "Bicubic Sharper (best for reduction)"]); export_to_dialog_window.ResampleSettings.selection = 4; // start with 0 // PANEL with Export Location export_to_dialog_window.ExportPanel = export_to_dialog_window.add('panel', undefined, 'Converted files output folder:'); // GROUP var Export_Group = export_to_dialog_window.ExportPanel.add( 'group', undefined, '') Export_Group.orientation = 'row'; Export_Group.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP]; Export_Group.size = [500,30]; // Edit var ExportEdit = Export_Group.add('edittext', undefined, msis_dialog_base_path); ExportEdit.size = [ 400,20 ]; // Choose Button var ExportChooseButton = Export_Group.add('button', undefined, 'Choose ...' ); ExportChooseButton.onClick = function() {msis_dialog_base_path = Folder.selectDialog().fsName; ExportEdit.text = msis_dialog_base_path; } // PANEL with Progressbar export_to_dialog_window.ProgressPanel = export_to_dialog_window.add('panel', undefined, 'Status:'); // GROUP var Progress_Group = export_to_dialog_window.ProgressPanel.add('group', undefined, '') Progress_Group.orientation = 'column'; Progress_Group.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP] Progress_Group.size = [500,5]; // progressbar export_to_dialog_window.ProgressProgressBar = export_to_dialog_window.ProgressPanel.add( 'progressbar', undefined, 0, 100 ); export_to_dialog_window.ProgressProgressBar.size = [480,10]; // label export_to_dialog_window.ProgressLabel = export_to_dialog_window.ProgressPanel.add('statictext', undefined, export_to_dialog_window.StackFileList.items.length + ' files are waiting for conversion.' ); export_to_dialog_window.ProgressLabel.size = [ 480,20 ]; // Buttons don't have a PANEL // GROUP Button_Group = export_to_dialog_window.add('group', undefined, ''); Button_Group.orientation = 'row' Button_Group.cancelBtn = Button_Group.add('button', undefined, 'Close', {name:'cancel'}); Button_Group.cancelBtn.onClick = function() { msis_file_dlg.close() }; Button_Group.okBtn = Button_Group.add('button', undefined, 'Convert', {name:'ok'}); Button_Group.okBtn.onClick = function() { msis_dialog_base_path = ExportEdit.text; Button_Group.okBtn.enabled = false; Button_Group.cancelBtn.enabled = false; Button_Group.aboutBtn.enabled = false; ExportEdit.enabled = false; ExportChooseButton.enabled = false; FileStackAddButton.enabled = false; FileStackRemoveButton.enabled = false; FileStackClearButton.enabled = false; export_to_dialog_window.myTrimCropSettings.enabled = false; export_to_dialog_window.myDPISettings.enabled = false; export_to_dialog_window.myColorSettings.enabled = false; export_to_dialog_window.myAntiAliasedSettings.enabled = false; export_to_dialog_window.myBitsSettings.enabled = false; msis_run_export(); Button_Group.okBtn.enabled = true; Button_Group.cancelBtn.enabled = true; Button_Group.aboutBtn.enabled = true; ExportEdit.enabled = true; ExportChooseButton.enabled = true; FileStackAddButton.enabled = true; FileStackRemoveButton.enabled = true; FileStackClearButton.enabled = true; export_to_dialog_window.myTrimCropSettings.enabled = true; export_to_dialog_window.myDPISettings.enabled = true; export_to_dialog_window.myColorSettings.enabled = true; export_to_dialog_window.myAntiAliasedSettings.enabled = true; export_to_dialog_window.myBitsSettings.enabled = true; }; Button_Group.aboutBtn = Button_Group.add('button', undefined, 'About', {name:'about'}); Button_Group.aboutBtn.onClick = function() { alert(msis_message_2); }; export_to_dialog_window.show(); } // ******************************************************************************************************** // ** ** // ** execute main routine when clicking at the Export button ** // ** ** // ******************************************************************************************************** function msis_run_export() { // no files added to stack if ( export_to_dialog_window.StackFileList.items.length == 0 ) { alert ('No files selected.\n\nChoose one or more files to convert before pressing the convert button.'); return; } // path specified if ( msis_dialog_base_path == '' ) { alert ('Invalid output folder.\n\nPlease specify an export location (output folder) for new documents.'); return; } // check if path exists var CheckPath = Folder(msis_dialog_base_path); if ( CheckPath.exists == 0) { alert ('Invalid output folder.\n\nPlease use the Choose Button to select your output folder.'); return; } //avoid displaying dialog boxes => All , ERROR , NO DebugAlerts ('Debug information [ 02 ] : Disable Dialog Mode'); app.displayDialogs = DialogModes.NO; //set units to pixels DebugAlerts ('Debug information [ 01 ] : Set units to pixels'); app.preferences.rulerUnits = Units.PIXELS; //define the pdf options for opening the document DebugAlerts ('Debug information [ 03 ] : Create PDF options container'); var pdfOpenOptions = new PDFOpenOptions(); DebugAlerts ('Debug information [ 04 ] : Supress PDF option warnings'); pdfOpenOptions.supressWarnings = true; // CropToType DebugAlerts ('Debug information [ 05 ] : Set pdfOpenOptions.cropPage = CropToType'); if ( export_to_dialog_window.myTrimCropSettings.selection == 0 ) {pdfOpenOptions.cropPage = CropToType.BOUNDINGBOX;} if ( export_to_dialog_window.myTrimCropSettings.selection == 1 ) {pdfOpenOptions.cropPage = CropToType.MEDIABOX;} if ( export_to_dialog_window.myTrimCropSettings.selection == 2 ) {pdfOpenOptions.cropPage = CropToType.CROPBOX;} if ( export_to_dialog_window.myTrimCropSettings.selection == 3 ) {pdfOpenOptions.cropPage = CropToType.BLEEDBOX;} if ( export_to_dialog_window.myTrimCropSettings.selection == 4 ) {pdfOpenOptions.cropPage = CropToType.TRIMBOX;} if ( export_to_dialog_window.myTrimCropSettings.selection == 5 ) {pdfOpenOptions.cropPage = CropToType.ARTBOX;} // Resolution DebugAlerts ('Debug information [ 06 ] : Set pdfOpenOptions.resolution ='); if ( export_to_dialog_window.myDPISettings.selection == 0 ) {pdfOpenOptions.resolution = 72;} if ( export_to_dialog_window.myDPISettings.selection == 1 ) {pdfOpenOptions.resolution = 100;} if ( export_to_dialog_window.myDPISettings.selection == 2 ) {pdfOpenOptions.resolution = 150;} if ( export_to_dialog_window.myDPISettings.selection == 3 ) {pdfOpenOptions.resolution = 200;} if ( export_to_dialog_window.myDPISettings.selection == 4 ) {pdfOpenOptions.resolution = 300;} if ( export_to_dialog_window.myDPISettings.selection == 5 ) {pdfOpenOptions.resolution = 600;} if ( export_to_dialog_window.myDPISettings.selection == 6 ) {pdfOpenOptions.resolution = 1200;} if ( export_to_dialog_window.myDPISettings.selection == 7 ) {pdfOpenOptions.resolution = 2400;} if ( export_to_dialog_window.myDPISettings.selection == 8 ) {pdfOpenOptions.resolution = 4800;} // OpenDocumentMode DebugAlerts ('Debug information [ 07 ] : Set pdfOpenOptions.mode = OpenDocumentMode'); if ( export_to_dialog_window.myColorSettings.selection == 0 ) {pdfOpenOptions.mode = OpenDocumentMode.GRAYSCALE;} if ( export_to_dialog_window.myColorSettings.selection == 1 ) {pdfOpenOptions.mode = OpenDocumentMode.RGB;} if ( export_to_dialog_window.myColorSettings.selection == 2 ) {pdfOpenOptions.mode = OpenDocumentMode.CMYK;} if ( export_to_dialog_window.myColorSettings.selection == 3 ) {pdfOpenOptions.mode = OpenDocumentMode.LAB;} // BitDepth DebugAlerts ('Debug information [ 08 ] : Set pdfOpenOptions.BitsPerChannel ='); if ( export_to_dialog_window.myBitsSettings.selection == 0 ) {pdfOpenOptions.bitsPerChannel = BitsPerChannelType.EIGHT;} if ( export_to_dialog_window.myBitsSettings.selection == 1 ) {pdfOpenOptions.bitsPerChannel = BitsPerChannelType.SIXTEEN;} if ( export_to_dialog_window.myBitsSettings.selection == 2 ) {pdfOpenOptions.bitsPerChannel = BitsPerChannelType.THIRTYTWO;} // Anti Alias DebugAlerts ('Debug information [ 09 ] : Set pdfOpenOptions.antiAlias ='); if ( export_to_dialog_window.myAntiAliasedSettings.value == false ) {pdfOpenOptions.antiAlias = false;} if ( export_to_dialog_window.myAntiAliasedSettings.value == true ) {pdfOpenOptions.antiAlias = true;} // define resolution for up downsampling DebugAlerts ('Debug information [ 10 ] : Set up/downsample resolution'); if ( export_to_dialog_window.UpDownDPISettings.selection == 0 ) {var UpDownSampleResolution = 72;} if ( export_to_dialog_window.UpDownDPISettings.selection == 1 ) {var UpDownSampleResolution = 100;} if ( export_to_dialog_window.UpDownDPISettings.selection == 2 ) {var UpDownSampleResolution = 150;} if ( export_to_dialog_window.UpDownDPISettings.selection == 3 ) {var UpDownSampleResolution = 200;} if ( export_to_dialog_window.UpDownDPISettings.selection == 4 ) {var UpDownSampleResolution = 300;} if ( export_to_dialog_window.UpDownDPISettings.selection == 5 ) {var UpDownSampleResolution = 600;} if ( export_to_dialog_window.UpDownDPISettings.selection == 6 ) {var UpDownSampleResolution = 1200;} if ( export_to_dialog_window.UpDownDPISettings.selection == 7 ) {var UpDownSampleResolution = 2400;} if ( export_to_dialog_window.UpDownDPISettings.selection == 8 ) {var UpDownSampleResolution = 4800;} // set progressbar counter var IncrementalValue = (100 / export_to_dialog_window.StackFileList.items.length) / 2; // 2 because update progress on both open and save export_to_dialog_window.ProgressProgressBar.value = 0; // set progressbar to 0; // process all files in stack for (var m=0; m < export_to_dialog_window.StackFileList.items.length; m++) { export_to_dialog_window.ProgressLabel.text = 'Rasterizing file ' + (m + 1) + ' out of ' + export_to_dialog_window.StackFileList.items.length + ' files. [ ' + export_to_dialog_window.StackFileList.items[m].text + ' ]'; export_to_dialog_window.ProgressProgressBar.value = export_to_dialog_window.ProgressProgressBar.value + IncrementalValue; export_to_dialog_window.update(); // try loading file into photoshop DebugAlerts ('Debug information [11] : Open PDF file'); try { open(fileList[m], pdfOpenOptions); } catch(err) { alert (err); } // try to set the layer name to the file name (instead of layer 1) // try { var TheFileNameItem = fileList[m]; // the ai or psd filename as shown in the listbox var TheFileName = TheFileNameItem.fsName; // to regular string var StrippedPathFileName = TheFileName.replace(/^.*[\\\/]/, ''); // without full path var NewFileName = StrippedPathFileName.substr(0, StrippedPathFileName.lastIndexOf('.')); app.activeDocument.activeLayer.name = NewFileName; } catch(err) { } // resampling the image DebugAlerts ('Debug information [ 12 ] : Set up/downsample method'); if (export_to_dialog_window.UpDownSampleSettings. value == true) { export_to_dialog_window.ProgressLabel.text = 'Resampling ' + (m + 1) + ' out of ' + export_to_dialog_window.StackFileList.items.length + ' files. [ ' + NewFileName + ' ]'; export_to_dialog_window.update(); try { if ( export_to_dialog_window.ResampleSettings.selection == 0 ) {app.activeDocument.resizeImage(undefined, undefined, UpDownSampleResolution, ResampleMethod.NEARESTNEIGHBOR);} if ( export_to_dialog_window.ResampleSettings.selection == 1 ) {app.activeDocument.resizeImage(undefined, undefined, UpDownSampleResolution, ResampleMethod.BILINEAR);} if ( export_to_dialog_window.ResampleSettings.selection == 2 ) {app.activeDocument.resizeImage(undefined, undefined, UpDownSampleResolution, ResampleMethod.BICUBIC);} if ( export_to_dialog_window.ResampleSettings.selection == 3 ) {app.activeDocument.resizeImage(undefined, undefined, UpDownSampleResolution, ResampleMethod.BICUBICSMOOTHER);} if ( export_to_dialog_window.ResampleSettings.selection == 4 ) {app.activeDocument.resizeImage(undefined, undefined, UpDownSampleResolution, ResampleMethod.BICUBICSHARPER);} } catch(err) { alert (err); } } // now we need to get the file path and new file extension // (amazing how much code one need to simply replace the file extension...........) try { var TheFileNameItem = fileList[m]; // the ai or psd filename as shown in the listbox var TheFileName = TheFileNameItem.fsName; // to regular string var StrippedPathFileName = TheFileName.replace(/^.*[\\\/]/, ''); // without full path var FileExtensionArray = StrippedPathFileName.split('.'); // split result into filename and extension var FileExtension = "." + FileExtensionArray[FileExtensionArray.length-1]; var NewFileName = StrippedPathFileName.replace (FileExtension, ".psd" ); // change extension in psd } catch(err) { alert (err); } // construct new path and filename try { var myPath = new Folder ( Folder (msis_dialog_base_path) ); var myFile = new File ( myPath + "/" + NewFileName ); } catch(err) { alert (err); } export_to_dialog_window.ProgressLabel.text = 'Saving file ' + (m + 1) + ' out of ' + export_to_dialog_window.StackFileList.items.length + ' files. [ ' + NewFileName + ' ]'; export_to_dialog_window.ProgressProgressBar.value = export_to_dialog_window.ProgressProgressBar.value + IncrementalValue; export_to_dialog_window.update(); // save file as psd DebugAlerts ('Debug information [ 11 ] : Save Photoshop file'); try { DebugAlerts ('Debug information [ 12 ] : Assign file name to PSD'); psdFile = new File( myFile ); DebugAlerts ('Debug information [ 13 ] : Create PSD container'); psdSaveOptions = new PhotoshopSaveOptions(); DebugAlerts ('Debug information [ 14 ] : Embed color profile'); psdSaveOptions.embedColorProfile = true; DebugAlerts ('Debug information [ 15 ] : Save with layers'); psdSaveOptions.layers = true; DebugAlerts ('Debug information [ 16 ] : Save file'); app.activeDocument.saveAs( psdFile, psdSaveOptions, false, Extension.LOWERCASE ); DebugAlerts ('Debug information [ 17 ] : Close File'); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); } catch(err) { alert (err); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); } } // show message that export is finished export_to_dialog_window.ProgressProgressBar.value = 100; export_to_dialog_window.ProgressLabel.text = 'Converted : ' + export_to_dialog_window.StackFileList.items.length + ' files into native Photoshop PSD file format'; //alert ('Converted : ' + export_to_dialog_window.StackFileList.items.length + ' files into native Photoshop PSD file format'); return; }