Batch Process Export Layers Script

I know how to break down a layered file using the Export Layers Script, and it works pretty well for me.  What I want to know is if there is a way to create an action using this script, that I can apply to multiple files and batch process in Bridge?  I have created an action that in theory should work, but I keep getting stop errors when I actually run it.  Has anyone successfully created an action that can export out multiple layers of multiple files?

Joyce,
Thank you.  Your suggestion helped clear my mental log jam.
Fireworks batch scripting seems to work in reverse.
Using "Batch Process..." scripting interface 'Export' (as JPEG) option first, 'Rename' (add Prefix) option second, and then follow these by using the history panel's 2 previously saved steps (Numeric Transform, Fit Canvas), batch process now works.  PNG file (list) is saved in targeted folder as a reduced scale JPEG with a prefixed file name.
Batch Process allows the entire newly defined command sequence to be saved (script.js).  Placing this (renamed) file into Firework's batch look-up directory for scripts (C:\Documents and Settings\account_name\Application Data\Adobe\Fireworks CS4\Commands) does not work.  The file name does not display in "Batch Process" window "Batch options:" Commands drop-down list.
Batch Process only works by recreating the above steps each use.
The new (JavaScript) file is 26 KB.  Is script file size limited in Fireworks "Batch options:" feature?

Similar Messages

  • Batch Process Export As and Save As JPEG Question?

    What is the method for creating scaled JPEGs from PNG files with batch processing (File | Batch Process...)?
    Application environment: Fireworks CS4.
    Using History panel, I manually captured instructions
    Modify | Transform | Numeric Transform (13%)
    Modify | Canvas | Fit Canvas
    File | Save As (JPEG)
    History panel's saved JavaScript file script:
    fw.getDocumentDOM().scaleSelection(0.11999999731779099, 0.11999999731779099, "autoTrimImages transformAttributes");
    fw.getDocumentDOM().setDocumentCanvasSizeToDocumentExtents(true);
    fw.saveDocumentAs(null, true);
    Running this sequence as a batch job requires manually selecting JPEG and "okaying"
    CS4 documentation for saveDocumentAs is defined with different argument list: fw.saveDocumentAs(document) .  CS4 documentation also has: fw.exportDocumentAs(document, fileURL, exportOptions) to export JPEG (80% quality).  CS4 feature File | Image Preview... | Export does not create a history record for guidance.  I cannot find an example of either instruction save a file to a local folder in JPEG format.  My objective is to add an additional batch step Rename (prefix) for the JPEG output, and script this a a batch process.

    Joyce,
    Thank you.  Your suggestion helped clear my mental log jam.
    Fireworks batch scripting seems to work in reverse.
    Using "Batch Process..." scripting interface 'Export' (as JPEG) option first, 'Rename' (add Prefix) option second, and then follow these by using the history panel's 2 previously saved steps (Numeric Transform, Fit Canvas), batch process now works.  PNG file (list) is saved in targeted folder as a reduced scale JPEG with a prefixed file name.
    Batch Process allows the entire newly defined command sequence to be saved (script.js).  Placing this (renamed) file into Firework's batch look-up directory for scripts (C:\Documents and Settings\account_name\Application Data\Adobe\Fireworks CS4\Commands) does not work.  The file name does not display in "Batch Process" window "Batch options:" Commands drop-down list.
    Batch Process only works by recreating the above steps each use.
    The new (JavaScript) file is 26 KB.  Is script file size limited in Fireworks "Batch options:" feature?

  • How to batch process multiple layers to jpegs

    I have over 500 layers of different texts over a simple background image. I need to move through each one of these layers, making only one and the background visible, then doing the same for the next, and saving each out as a separate .jpeg. I know how to batch process the jpegs giving each a different filename, but how do I move through the layers?
    Thanks.

    Hi, Paul--
    You were correct. The normal script didn't work at all. But I'm a bit confused about how to use Layer Saver. I currently have all the texts in groups, labelled 1-50, 51-100, etc. What settings should I use to get it to work?
    Thanks
    J.

  • Batch Processing when Integration script is used

    Can we set up batch processing when we are using integration scripts to connect to source tables? If yes, then what are the settings required ?
    Thanks

    You need to create an empty flat file in the Openbatch folder (assuming you are using the single period load). the format for the file name is in the admin guide. I generally add this to the batch script before the batch process section.

  • Batch Process - Export Settings - File Name Template syntax?

    Can anyone explain the syntax for the File Name Templates in the Export Settings of Batch Process?  Back in the good ol days of Audition 3, I could use ???????? to keep just the first 8 characters of the original filename for my processed files.  In CS6 there are a few templates, but no decent explanation as to what they do or how to create your own.  Can anyone shed some light? 

    Yes, I believe %n is the original name, but what sort of syntax is available to modify the filename ?  There is one that does "%a\%d\%t -%s" for instance, but I don't know what it does.  And you aren't allowed to use * or ? characters, which really limits wildcarding. 
    The one I am needing to do is rename original files that are 12 characters long -- 00000x00_001.wav -- to just the first 8 characters -- 00000x00.wav
    I should probably put this in another post, but does anyone know offhand how to get the "interpret sample rate as" to work in a batch "favorite" process?  I do the action when I am creating the "Favorite" but it skips that step when applying it to a file. 

  • How to execute a batch processing thought a script

    Hi all,
    I have created a batch processing with Executing a javascript. B'coz i have to open multiple files, so that i m using batch processing.
    Now i m want to execute the particular batch process through the javascript.
    Is it possible to run through javascript?
    Please let me know your ideas or suggesions.
    Thanks and regards,
    Christy.

    Hi George,
    Actually my process is need to open multiple Forms in Acrobat 9, Clear the form fields, and enable the submenu "Extend Featurs in Adobe Reader " which is in "Advance" menu.
    I m trying to do this process using Acrobat javascript.
    Thanks and Regards,
    Christy

  • Export layers to file script error in Photoshop CC

    I need help with an issue.  I also asked this in the general forum but was refered here to ask all of you amazingly talented scripting geniuses.
    My issue is with the Export Layers script that comes installed with Photoshop.  I am running Windows 7 64bit - using photoshop version: creative cloud 64bit.
    When i try to run File>Scripts> Export Layers to files I get this error
    Error 22: Windows does not have a constructor. Line: 239 -> dlgMain = new Window ("dialog", strTitle); 
    When i load Photoshop Creative Cloud 32 bit i get a different error message when trying to run the script. 
    Error - 33: Internal error . line:395 ->  dligMain.pnlFileType.pnlOptions.grpJPGOptions = ...
    I can't run the image processor script I also get an error with that. 
    This  is an issue for me as i use this script on a daily basis.  It worked in PSCS6  
    I upgraded, i dont' want to have to load an older  version of photoshop to do this task  
    Thanks
    Carrie 

    I'm afraid no ideas...
    These kind of errors appeared to me too (Mac, CS5/CS6). If memory doesn't fail me - and there were tricks to be applied in your own scripts to workaround the problem - the issue was due to a stack of commands involving Document change (say: switch from document A to document B and then activate the layer X): what happened was that the script's call "activate the layer X" was too quick - i.e. it happened before Photoshop could actually perform the switch. As a result the "activate the Layer X" was executed on the A document instead of the B document and the whole thing broke.
    Mind you, it's just an example I've made up.
    Tab view for some reason worked as expected.
    I would suggest to try with no other documents open, resetting the preferences (launch PS pressing CRTL+ALT+SHIFT) - but this is quite generic, as a recommendation.
    Davide

  • Command line / batch processing

    To be honest, I've only ever used acrobat to read pdfs. That's it. But now I'm trying to put together a packet for work from a bunch of pdfs. Basically, I'll end up with 10+ pdf files with multiple pages each, but I only want my packet to have usually just one page out of each of the original pdfs.
    That doesn't seem so clear... I start with a bunch of multi page pdfs. Find the page I want, rename the file to "pageIWantNumber OriginalTitle.pdf" (ie "4 ee_5401_33428").
    Then, later on, I want to print out only the selected pages, like in my ie only page 4 from that pdf. Now if I have to just print these to printer that's ok but not ideal.
    Ideally I'd like to end up with either multiple pdf files with only one page (so the multiple page pdfs get cut down to only one page, but there are still a bunch of them). And/or then concat them all together to get a multipage single pdf that has each single page from the original multiple page pdfs.
    It's not as complicated as it is to explain I don't think.. Hopefully you guys understand. My goal is to automate this, using the space in the filename as a delimiter or something so I can just get all of these done really quickly.

    I found this in another post:
    Geo Kaiser - 2:25pm Jan 25, 08 PST (#1 of 3)
    Have you looked at the "Print 1st Page" batch process?
    The script for that command is:
    /* Print 1st Page */
    /* This sequence prints the first page of
    each document selected to the default printer.
    / this.print
    bUI: false,
    nStart: 0,
    bSilent: true
    So you can ceate a new batch process and copy the 1st page script and then add the "nEnd" parameter:
    /* Print Pages 1-5 */
    /* This sequence prints the first six pages of
    each document selected to the default printer.
    / this.print
    bUI: false,
    nStart: 0,
    nEnd: 5,
    bSilent: true
    Which is very similar to what I want to do, but I need to pull off the nStart value from the file name somehow. So "6 4 2 ee-325" would produce something like:
    "nStart:2, nStart:4, nStart:6" or something.
    Doing this through a .bat file of some sort would be ideal, so maybe I could do the file name parsing through the .bat file and then use a command line interface to adobe to get this done?
    ie:
    acrobat.exe filename.pdf -print 2
    acrobat.exe filename.pdf -print 4
    acrobat.exe filename.pdf -print 6

  • How batch export layers to files png in cc

    I am having trouble with an export layers to files script i am wanting to batch export layer to png and this script i have seems to be the one i want although every time i run the script i get this error message "could not complete the action  since the destination folder doesn't exist" the script required me to hard code my destination path the path i require is "C:/Users/Tim/Desktop/Backdrops/png/" I am not completely sure why its stating it does not exist any help would be greatly appreciated. i have tried to contact the creator but the post it was on was very old.
    // enable double clicking from the Macintosh Finder or the Windows Explorer
    #target photoshop
    //=================================================================
    // Globals
    //=================================================================
    var exportPath = "/Users/pedr/Documents/Work/Clients/Pathways/Learning_Hub/Source/Comics/export";
    exportPath = exportPath + '/layers';
    // UI strings to be localized
    var strTitle = localize("$$$/JavaScripts/X2L/Title=X2L");
    var strButtonRun = localize("$$$/JavaScripts/X2L/Run=Run");
    var strButtonCancel = localize("$$$/JavaScripts/X2L/Cancel=Cancel");
    var strHelpText = localize("$$$/JavaScripts/X2L/Help=Please specify the format and location for saving each layer as a file.");
    var strLabelDestination = localize("$$$/JavaScripts/X2L/Destination=Destination:");
    var strButtonBrowse = localize("$$$/JavaScripts/X2L/Browse=&Browse...");
    var strLabelFileNamePrefix = localize("$$$/JavaScripts/X2L/FileNamePrefix=File Name Prefix:");
    var strCheckboxVisibleOnly = localize("$$$/JavaScripts/X2L/VisibleOnly=&Visible Layers Only");
    var strLabelFileType = localize("$$$/JavaScripts/X2L/FileType=File Type:");
    var strCheckboxIncludeICCProfile = localize("$$$/JavaScripts/X2L/IncludeICC=&Include ICC Profile");
    var strJPEGOptions = localize("$$$/JavaScripts/X2L/JPEGOptions=JPEG Options:");
    var strLabelQuality = localize("$$$/JavaScripts/X2L/Quality=Quality:");
    var strCheckboxMaximizeCompatibility = localize("$$$/JavaScripts/X2L/Maximize=&Maximize Compatibility");
    var strTIFFOptions = localize("$$$/JavaScripts/X2L/TIFFOptions=TIFF Options:");
    var strLabelImageCompression = localize("$$$/JavaScripts/X2L/ImageCompression=Image Compression:");
    var strNone = localize("$$$/JavaScripts/X2L/None=None");
    var strPDFOptions = localize("$$$/JavaScripts/X2L/PDFOptions=PDF Options:");
    var strLabelEncoding = localize("$$$/JavaScripts/X2L/Encoding=Encoding:");
    var strTargaOptions = localize("$$$/JavaScripts/X2L/TargaOptions=Targa Options:");
    var strLabelDepth = localize("$$$/JavaScripts/X2L/Depth=Depth:");
    var strRadiobutton16bit = localize("$$$/JavaScripts/X2L/Bit16=16bit");
    var strRadiobutton24bit = localize("$$$/JavaScripts/X2L/Bit24=24bit");
    var strRadiobutton32bit = localize("$$$/JavaScripts/X2L/Bit32=32bit");
    var strBMPOptions = localize("$$$/JavaScripts/X2L/BMPOptions=BMP Options:");
    var strAlertSpecifyDestination = localize("$$$/JavaScripts/X2L/SpecifyDestination=Please specify destination.");
    var strAlertDestinationNotExist = localize("$$$/JavaScripts/X2L/DestionationDoesNotExist=Destination does not exist.");
    var strTitleSelectDestination = localize("$$$/JavaScripts/X2L/SelectDestination=Select Destination");
    var strAlertDocumentMustBeOpened = localize("$$$/JavaScripts/X2L/OneDocument=You must have a document open to export!");
    var strAlertNeedMultipleLayers = localize("$$$/JavaScripts/X2L/NoLayers=You need a document with multiple layers to export!");
    var strAlertWasSuccessful = localize("$$$/JavaScripts/X2L/Success= was successful.");
    var strUnexpectedError = localize("$$$/JavaScripts/X2L/Unexpected=Unexpected error");
    var strMessage = localize("$$$/JavaScripts/X2L/Message=X2L");
    var stretQuality = localize( "$$$/locale_specific/JavaScripts/X2L/ETQualityLength=30" );
    var stretDestination = localize( "$$$/locale_specific/JavaScripts/X2L/ETDestinationLength=160" );
    var strddFileType = localize( "$$$/locale_specific/JavaScripts/X2L/DDFileType=100" );
    var strpnlOptions = localize( "$$$/locale_specific/JavaScripts/X2L/PNLOptions=100" );
    var strPNG8Options = localize("$$$/JavaScripts/X2L/PNG8Options=PNG-8 Options:");
    var strCheckboxPNGTransparency = localize("$$$/JavaScripts/X2L/Transparency=Transparency");
    var strCheckboxPNGInterlaced = localize("$$$/JavaScripts/X2L/Interlaced=Interlaced");
    var strCheckboxPNGTrm = localize("$$$/JavaScripts/X2L/Trim=Trim Layers");
    var strPNG24Options = localize("$$$/JavaScripts/X2L/PNG24Options=PNG-24 Options:");
    // the drop down list indexes for file type
    var png24Index = 7;
    main();
    // Functions
    // Function: main
    // Usage: the core routine for this script
    // Input: <none>
    // Return: <none>
    function main() {
        if ( app.documents.length <= 0 ) {
            if ( DialogModes.NO != app.playbackDisplayDialogs ) {
                alert( strAlertDocumentMustBeOpened );
            return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
        var exportInfo = new Object();
        initExportInfo(exportInfo);
        // look for last used params via Photoshop registry, getCustomOptions will throw if none exist
        try {
        catch(e) {
            // it's ok if we don't have any options, continue with defaults
        try {
            var docName = app.activeDocument.name;  // save the app.activeDocument name before duplicate.
            var layerCount = app.documents[docName].layers.length;
            var layerSetsCount = app.documents[docName].layerSets.length;
            if ((layerCount <= 1)&&(layerSetsCount <= 0)) {
                if ( DialogModes.NO != app.playbackDisplayDialogs ) {
                    alert( strAlertNeedMultipleLayers );
                return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
            } else {
                var rememberMaximize;
                var needMaximize = exportInfo.psdMaxComp ? QueryStateType.ALWAYS : QueryStateType.NEVER;
                app.activeDocument = app.documents[docName];
                var duppedDocument = app.activeDocument.duplicate();
                duppedDocument.activeLayer = duppedDocument.layers[duppedDocument.layers.length-1]; // for removing
                setInvisibleAllArtLayers(duppedDocument);
                exportChildren(duppedDocument, app.documents[docName], exportInfo, duppedDocument, exportInfo.fileNamePrefix);
                duppedDocument.close( SaveOptions.DONOTSAVECHANGES );
                if ( rememberMaximize != undefined ) {
                    app.preferences.maximizeCompatibility = rememberMaximize;
                if ( DialogModes.ALL == app.playbackDisplayDialogs ) {
                    //alert(strTitle + strAlertWasSuccessful);
                app.playbackDisplayDialogs = DialogModes.ALL;
        } catch (e) {
            if ( DialogModes.NO != app.playbackDisplayDialogs ) {
                alert(e);
            return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
    // Function: settingDialog
    // Usage: pop the ui and get user settings
    // Input: exportInfo object containing our parameters
    // Return: on ok, the dialog info is set to the exportInfo object
    function settingDialog(exportInfo) {
      return;
    // Function: hideAllFileTypePanel
    // Usage: hide all the panels in the common actions
    // Input: <none>, dlgMain is a global for this script
    // Return: <none>, all panels are now hidden
    function hideAllFileTypePanel() {
    // Function: initExportInfo
    // Usage: create our default parameters
    // Input: a new Object
    // Return: a new object with params set to default
    function initExportInfo(exportInfo) {
        //exportInfo.destination = new String(exportPath);
        exportInfo.fileNamePrefix = new String("untitled_");
        exportInfo.visibleOnly = false;
        exportInfo.fileType = png24Index;
        exportInfo.icc = true;
        exportInfo.png24Transparency = true;
        exportInfo.png24Interlaced = false;
        exportInfo.png24Trim = true;
        try {
            exportInfo.destination = Folder(new String(exportPath)).fsName; // destination folder
            var tmp = app.activeDocument.fullName.name;
            exportInfo.fileNamePrefix = decodeURI(tmp.substring(0, tmp.indexOf("."))); // filename body part
        } catch(someError) {
            exportInfo.destination = new String(exportPath);
            exportInfo.fileNamePrefix = app.activeDocument.name; // filename body part
    // Function: saveFile
    // Usage: the worker routine, take our params and save the file accordingly
    // Input: reference to the document, the name of the output file,
    //        export info object containing more information
    // Return: <none>, a file on disk
    function saveFile( docRef, fileNameBody, exportInfo) {
                saveFile(docRef, fileNameBody, exportInfo, false, true);
                function saveFile( docRef, fileNameBody, exportInfo, interlacedValue, transparencyValue) {
                var id6 = charIDToTypeID( "Expr" );
                    var desc3 = new ActionDescriptor();
                    var id7 = charIDToTypeID( "Usng" );
                        var desc4 = new ActionDescriptor();
                        var id8 = charIDToTypeID( "Op  " );
                        var id9 = charIDToTypeID( "SWOp" );
                        var id10 = charIDToTypeID( "OpSa" );
                        desc4.putEnumerated( id8, id9, id10 );
                        var id11 = charIDToTypeID( "Fmt " );
                        var id12 = charIDToTypeID( "IRFm" );
                        var id13 = charIDToTypeID( "PN24" );
                        desc4.putEnumerated( id11, id12, id13 );
                        var id14 = charIDToTypeID( "Intr" );
                        desc4.putBoolean( id14, interlacedValue );
                        var id15 = charIDToTypeID( "Trns" );
                        desc4.putBoolean( id15, transparencyValue );
                        var id16 = charIDToTypeID( "Mtt " );
                        desc4.putBoolean( id16, true );
                        var id17 = charIDToTypeID( "MttR" );
                        desc4.putInteger( id17, 255 );
                        var id18 = charIDToTypeID( "MttG" );
                        desc4.putInteger( id18, 255 );
                        var id19 = charIDToTypeID( "MttB" );
                        desc4.putInteger( id19, 255 );
                        var id20 = charIDToTypeID( "SHTM" );
                        desc4.putBoolean( id20, false );
                        var id21 = charIDToTypeID( "SImg" );
                        desc4.putBoolean( id21, true );
                        var id22 = charIDToTypeID( "SSSO" );
                        desc4.putBoolean( id22, false );
                        var id23 = charIDToTypeID( "SSLt" );
                            var list1 = new ActionList();
                        desc4.putList( id23, list1 );
                        var id24 = charIDToTypeID( "DIDr" );
                        desc4.putBoolean( id24, false );
                        var id25 = charIDToTypeID( "In  " );
                        desc4.putPath( id25, new File( exportPath + "C:/Users/Tim/Desktop/Backdrops/png/"  + fileNameBody + ".png") );
                    var id26 = stringIDToTypeID( "SaveForWeb" );
                    desc3.putObject( id7, id26, desc4 );
                executeAction( id6, desc3, DialogModes.NO );
    // Function: zeroSuppress
    // Usage: return a string padded to digit(s)
    // Input: num to convert, digit count needed
    // Return: string padded to digit length
    function zeroSuppress (num, digit) {
        var tmp = num.toString();
        while (tmp.length < digit) {
            tmp = "0" + tmp;
        return tmp;
    // Function: setInvisibleAllArtLayers
    // Usage: unlock and make invisible all art layers, recursively
    // Input: document or layerset
    // Return: all art layers are unlocked and invisible
    function setInvisibleAllArtLayers(obj) {
        for( var i = 0; i < obj.artLayers.length; i++) {
            obj.artLayers[i].allLocked = false;
            obj.artLayers[i].visible = false;
        for( var i = 0; i < obj.layerSets.length; i++) {
            setInvisibleAllArtLayers(obj.layerSets[i]);
    // Function: removeAllInvisibleArtLayers
    // Usage: remove all the invisible art layers, recursively
    // Input: document or layer set
    // Return: <none>, all layers that were invisible are now gone
    function removeAllInvisibleArtLayers(obj) {
        for( var i = obj.artLayers.length-1; 0 <= i; i--) {
            try {
                if(!obj.artLayers[i].visible) {
                    obj.artLayers[i].remove();
            catch (e) {
        for( var i = obj.layerSets.length-1; 0 <= i; i--) {
            removeAllInvisibleArtLayers(obj.layerSets[i]);
    // Function: removeAllEmptyLayerSets
    // Usage: find all empty layer sets and remove them, recursively
    // Input: document or layer set
    // Return: empty layer sets are now gone
    function removeAllEmptyLayerSets(obj) {
        var foundEmpty = true;
        for( var i = obj.layerSets.length-1; 0 <= i; i--) {
            if( removeAllEmptyLayerSets(obj.layerSets[i])) {
                obj.layerSets[i].remove();
            } else {
                foundEmpty = false;
        if (obj.artLayers.length > 0) {
            foundEmpty = false;
        return foundEmpty;
    // Function: zeroSuppress
    // Usage: return a string padded to digit(s)
    // Input: num to convert, digit count needed
    // Return: string padded to digit length
    function removeAllInvisible(docRef) {
        removeAllInvisibleArtLayers(docRef);
        removeAllEmptyLayerSets(docRef);
    // Function: exportChildren
    // Usage: find all the children in this document to save
    // Input: duplicate document, original document, export info,
    //        reference to document, starting file name
    // Return: <none>, documents are saved accordingly
    function exportChildren(dupObj, orgObj, exportInfo, dupDocRef, fileNamePrefix) {
        for( var i = 0; i < dupObj.artLayers.length; i++) {
            if (exportInfo.visibleOnly) { // visible layer only
                if (!orgObj.artLayers[i].visible) {
                    continue;
            dupObj.artLayers[i].visible = true;
            var layerName = dupObj.artLayers[i].name;  // store layer name before change doc
            var duppedDocumentTmp = dupDocRef.duplicate();
            if ((png24Index == exportInfo.fileType)||(png8Index == exportInfo.fileType)) { // PSD: Keep transparency
                removeAllInvisible(duppedDocumentTmp);
                //PNGFileOptions
                        if (activeDocument.activeLayer.isBackgroundLayer == false) { //is it anything but a background layer?
                            app.activeDocument.trim(TrimType.TRANSPARENT);
            } else { // just flatten
                duppedDocumentTmp.flatten();
            // Edit
            var docName = app.activeDocument.name;
            // For some reason indexOf fails if we include the '-', so we use 'copy' and decrement the index by 1.
            docName = docName.slice(0, docName.indexOf('copy')-1);
            var fileNameBody = (docName+'_'+layerName).toLowerCase();
            fileNameBody = fileNameBody.replace(/[:\/\\*\?\"\<\>\|]/g, "_");  // '/\:*?"<>|' -> '_'
            if (fileNameBody.length > 120) {
                fileNameBody = fileNameBody.substring(0,120);
            saveFile(duppedDocumentTmp, fileNameBody, exportInfo);
            duppedDocumentTmp.close(SaveOptions.DONOTSAVECHANGES);
            dupObj.artLayers[i].visible = false;
        for( var i = 0; i < dupObj.layerSets.length; i++) {
            if (exportInfo.visibleOnly) { // visible layer only
                if (!orgObj.layerSets[i].visible) {
                    continue;
            var fileNameBody = fileNamePrefix;
            fileNameBody += "_" + zeroSuppress(i, 4) + "s";
            exportChildren(dupObj.layerSets[i], orgObj.layerSets[i], exportInfo, dupDocRef, fileNameBody);  // recursive call
    // Function: objectToDescriptor
    // Usage: create an ActionDescriptor from a JavaScript Object
    // Input: JavaScript Object (o)
    //        object unique string (s)
    //        Pre process converter (f)
    // Return: ActionDescriptor
    // NOTE: Only boolean, string, number and UnitValue are supported, use a pre processor
    //       to convert (f) other types to one of these forms.
    // REUSE: This routine is used in other scripts. Please update those if you
    //        modify. I am not using include or eval statements as I want these
    //        scripts self contained.
    function objectToDescriptor (o, s, f) {
        o = {};
        var d = new ActionDescriptor;
        var l = o.reflect.properties.length;
        d.putString( app.charIDToTypeID( 'Msge' ), s );
        for (var i = 0; i < l; i++ ) {
            var k = o.reflect.properties[i].toString();
            if (k == "__proto__" || k == "__count__" || k == "__class__" || k == "reflect")
                continue;
            var v = o[ k ];
            k = app.stringIDToTypeID(k);
            switch ( typeof(v) ) {
                case "boolean":
                    d.putBoolean(k, v);
                    break;
                case "string":
                    d.putString(k, v);
                    break;
                case "number":
                    d.putDouble(k, v);
                    break;
                default:
                    if ( v instanceof UnitValue ) {
                        var uc = new Object;
                        uc["px"] = charIDToTypeID("#Rlt"); // unitDistance
                        uc["%"] = charIDToTypeID("#Prc"); // unitPercent
                        d.putUnitDouble(k, uc[v.type], v.value);
                    } else {
                        throw( new Error("Unsupported type in objectToDescriptor " + typeof(v) ) );
        return d;
    // Function: descriptorToObject
    // Usage: update a JavaScript Object from an ActionDescriptor
    // Input: JavaScript Object (o), current object to update (output)
    //        Photoshop ActionDescriptor (d), descriptor to pull new params for object from
    //        object unique string (s)
    //        JavaScript Function (f), post process converter utility to convert
    // Return: Nothing, update is applied to passed in JavaScript Object (o)
    // NOTE: Only boolean, string, number and UnitValue are supported, use a post processor
    //       to convert (f) other types to one of these forms.
    // REUSE: This routine is used in other scripts. Please update those if you
    //        modify. I am not using include or eval statements as I want these
    //        scripts self contained.
    function descriptorToObject (o, d, s, f) {
        var l = d.count;
        if (l) {
            var keyMessage = app.charIDToTypeID( 'Msge' );
            if ( d.hasKey(keyMessage) && ( s != d.getString(keyMessage) )) return;
        for (var i = 0; i < l; i++ ) {
            var k = d.getKey(i); // i + 1 ?
            var t = d.getType(k);
            strk = app.typeIDToStringID(k);
            switch (t) {
                case DescValueType.BOOLEANTYPE:
                    o[strk] = d.getBoolean(k);
                    break;
                case DescValueType.STRINGTYPE:
                    o[strk] = d.getString(k);
                    break;
                case DescValueType.DOUBLETYPE:
                    o[strk] = d.getDouble(k);
                    break;
                case DescValueType.UNITDOUBLE:
                    var uc = new Object;
                    uc[charIDToTypeID("#Rlt")] = "px"; // unitDistance
                    uc[charIDToTypeID("#Prc")] = "%"; // unitPercent
                    uc[charIDToTypeID("#Pxl")] = "px"; // unitPixels
                    var ut = d.getUnitDoubleType(k);
                    var uv = d.getUnitDoubleValue(k);
                    o[strk] = new UnitValue( uv, uc[ut] );
                    break;
                case DescValueType.INTEGERTYPE:
                case DescValueType.ALIASTYPE:
                case DescValueType.CLASSTYPE:
                case DescValueType.ENUMERATEDTYPE:
                case DescValueType.LISTTYPE:
                case DescValueType.OBJECTTYPE:
                case DescValueType.RAWTYPE:
                case DescValueType.REFERENCETYPE:
                default:
                    throw( new Error("Unsupported type in descriptorToObject " + t ) );
        if (undefined != f) {
            o = f(o);
    // Function: preProcessExportInfo
    // Usage: convert Photoshop enums to strings for storage
    // Input: JavaScript Object of my params for this script
    // Return: JavaScript Object with objects converted for storage
    function preProcessExportInfo(o) {
        o.tiffCompression = o.tiffCompression.toString();
        o.pdfEncoding = o.pdfEncoding.toString();
        o.targaDepth = o.targaDepth.toString();
        o.bmpDepth = o.bmpDepth.toString();
        return o;
    // Function: postProcessExportInfo
    // Usage: convert strings from storage to Photoshop enums
    // Input: JavaScript Object of my params in string form
    // Return: JavaScript Object with objects in enum form
    function postProcessExportInfo(o) {
        o.tiffCompression = eval(o.tiffCompression);
        o.pdfEncoding = eval(o.pdfEncoding);
        o.targaDepth = eval(o.targaDepth);
        o.bmpDepth = eval(o.bmpDepth);
        return o;
    // Function: StrToIntWithDefault
    // Usage: convert a string to a number, first stripping all characters
    // Input: string and a default number
    // Return: a number
    function StrToIntWithDefault( s, n ) {
        var onlyNumbers = /[^0-9]/g;
        var t = s.replace( onlyNumbers, "" );
        t = parseInt( t );
        if ( ! isNaN( t ) ) {
            n = t;
        return n;
    // End X2L.jsx

    I have put the like var exportPath = "~/Desktop/Backdrops/png/";  and have removed the exportPath = exportPath + '/layers';
    but when i run the script it still comes up with the error
    could not complete action since the destination folder does not exist
    if you are using the extendedscript toolkit would be able to run the script and see if you know were the problem is coming from i cant seem to understand why its not seeing the destination.
    thanks for all your help
    // enable double clicking from the Macintosh Finder or the Windows Explorer
    #target photoshop
    //=================================================================
    // Globals
    //=================================================================
    var exportPath = "~/Desktop/Backdrops/png/";
    // UI strings to be localized
    var strTitle = localize("$$$/JavaScripts/X2L/Title=X2L");
    var strButtonRun = localize("$$$/JavaScripts/X2L/Run=Run");
    var strButtonCancel = localize("$$$/JavaScripts/X2L/Cancel=Cancel");
    var strHelpText = localize("$$$/JavaScripts/X2L/Help=Please specify the format and location for saving each layer as a file.");
    var strLabelDestination = localize("$$$/JavaScripts/X2L/Destination=Destination:");
    var strButtonBrowse = localize("$$$/JavaScripts/X2L/Browse=&Browse...");
    var strLabelFileNamePrefix = localize("$$$/JavaScripts/X2L/FileNamePrefix=File Name Prefix:");
    var strCheckboxVisibleOnly = localize("$$$/JavaScripts/X2L/VisibleOnly=&Visible Layers Only");
    var strLabelFileType = localize("$$$/JavaScripts/X2L/FileType=File Type:");
    var strCheckboxIncludeICCProfile = localize("$$$/JavaScripts/X2L/IncludeICC=&Include ICC Profile");
    var strJPEGOptions = localize("$$$/JavaScripts/X2L/JPEGOptions=JPEG Options:");
    var strLabelQuality = localize("$$$/JavaScripts/X2L/Quality=Quality:");
    var strCheckboxMaximizeCompatibility = localize("$$$/JavaScripts/X2L/Maximize=&Maximize Compatibility");
    var strTIFFOptions = localize("$$$/JavaScripts/X2L/TIFFOptions=TIFF Options:");
    var strLabelImageCompression = localize("$$$/JavaScripts/X2L/ImageCompression=Image Compression:");
    var strNone = localize("$$$/JavaScripts/X2L/None=None");
    var strPDFOptions = localize("$$$/JavaScripts/X2L/PDFOptions=PDF Options:");
    var strLabelEncoding = localize("$$$/JavaScripts/X2L/Encoding=Encoding:");
    var strTargaOptions = localize("$$$/JavaScripts/X2L/TargaOptions=Targa Options:");
    var strLabelDepth = localize("$$$/JavaScripts/X2L/Depth=Depth:");
    var strRadiobutton16bit = localize("$$$/JavaScripts/X2L/Bit16=16bit");
    var strRadiobutton24bit = localize("$$$/JavaScripts/X2L/Bit24=24bit");
    var strRadiobutton32bit = localize("$$$/JavaScripts/X2L/Bit32=32bit");
    var strBMPOptions = localize("$$$/JavaScripts/X2L/BMPOptions=BMP Options:");
    var strAlertSpecifyDestination = localize("$$$/JavaScripts/X2L/SpecifyDestination=Please specify destination.");
    var strAlertDestinationNotExist = localize("$$$/JavaScripts/X2L/DestionationDoesNotExist=Destination does not exist.");
    var strTitleSelectDestination = localize("$$$/JavaScripts/X2L/SelectDestination=Select Destination");
    var strAlertDocumentMustBeOpened = localize("$$$/JavaScripts/X2L/OneDocument=You must have a document open to export!");
    var strAlertNeedMultipleLayers = localize("$$$/JavaScripts/X2L/NoLayers=You need a document with multiple layers to export!");
    var strAlertWasSuccessful = localize("$$$/JavaScripts/X2L/Success= was successful.");
    var strUnexpectedError = localize("$$$/JavaScripts/X2L/Unexpected=Unexpected error");
    var strMessage = localize("$$$/JavaScripts/X2L/Message=X2L");
    var stretQuality = localize( "$$$/locale_specific/JavaScripts/X2L/ETQualityLength=30" );
    var stretDestination = localize( "$$$/locale_specific/JavaScripts/X2L/ETDestinationLength=160" );
    var strddFileType = localize( "$$$/locale_specific/JavaScripts/X2L/DDFileType=100" );
    var strpnlOptions = localize( "$$$/locale_specific/JavaScripts/X2L/PNLOptions=100" );
    var strPNG8Options = localize("$$$/JavaScripts/X2L/PNG8Options=PNG-8 Options:");
    var strCheckboxPNGTransparency = localize("$$$/JavaScripts/X2L/Transparency=Transparency");
    var strCheckboxPNGInterlaced = localize("$$$/JavaScripts/X2L/Interlaced=Interlaced");
    var strCheckboxPNGTrm = localize("$$$/JavaScripts/X2L/Trim=Trim Layers");
    var strPNG24Options = localize("$$$/JavaScripts/X2L/PNG24Options=PNG-24 Options:");
    // the drop down list indexes for file type
    var png24Index = 7;
    main();
    // Functions
    // Function: main
    // Usage: the core routine for this script
    // Input: <none>
    // Return: <none>
    function main() {
        if ( app.documents.length <= 0 ) {
            if ( DialogModes.NO != app.playbackDisplayDialogs ) {
                alert( strAlertDocumentMustBeOpened );
            return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
        var exportInfo = new Object();
        initExportInfo(exportInfo);
        // look for last used params via Photoshop registry, getCustomOptions will throw if none exist
        try {
        catch(e) {
            // it's ok if we don't have any options, continue with defaults
        try {
            var docName = app.activeDocument.name;  // save the app.activeDocument name before duplicate.
            var layerCount = app.documents[docName].layers.length;
            var layerSetsCount = app.documents[docName].layerSets.length;
            if ((layerCount <= 1)&&(layerSetsCount <= 0)) {
                if ( DialogModes.NO != app.playbackDisplayDialogs ) {
                    alert( strAlertNeedMultipleLayers );
                return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
            } else {
                var rememberMaximize;
                var needMaximize = exportInfo.psdMaxComp ? QueryStateType.ALWAYS : QueryStateType.NEVER;
                app.activeDocument = app.documents[docName];
                var duppedDocument = app.activeDocument.duplicate();
                duppedDocument.activeLayer = duppedDocument.layers[duppedDocument.layers.length-1]; // for removing
                setInvisibleAllArtLayers(duppedDocument);
                exportChildren(duppedDocument, app.documents[docName], exportInfo, duppedDocument, exportInfo.fileNamePrefix);
                duppedDocument.close( SaveOptions.DONOTSAVECHANGES );
                if ( rememberMaximize != undefined ) {
                    app.preferences.maximizeCompatibility = rememberMaximize;
                if ( DialogModes.ALL == app.playbackDisplayDialogs ) {
                    //alert(strTitle + strAlertWasSuccessful);
                app.playbackDisplayDialogs = DialogModes.ALL;
        } catch (e) {
            if ( DialogModes.NO != app.playbackDisplayDialogs ) {
                alert(e);
            return 'cancel'; // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
    // Function: settingDialog
    // Usage: pop the ui and get user settings
    // Input: exportInfo object containing our parameters
    // Return: on ok, the dialog info is set to the exportInfo object
    function settingDialog(exportInfo) {
      return;
    // Function: hideAllFileTypePanel
    // Usage: hide all the panels in the common actions
    // Input: <none>, dlgMain is a global for this script
    // Return: <none>, all panels are now hidden
    function hideAllFileTypePanel() {
    // Function: initExportInfo
    // Usage: create our default parameters
    // Input: a new Object
    // Return: a new object with params set to default
    function initExportInfo(exportInfo) {
        //exportInfo.destination = new String(exportPath);
        exportInfo.fileNamePrefix = new String("untitled_");
        exportInfo.visibleOnly = false;
        exportInfo.fileType = png24Index;
        exportInfo.icc = true;
        exportInfo.png24Transparency = true;
        exportInfo.png24Interlaced = false;
        exportInfo.png24Trim = true;
        try {
            exportInfo.destination = Folder(new String(exportPath)).fsName; // destination folder
            var tmp = app.activeDocument.fullName.name;
            exportInfo.fileNamePrefix = decodeURI(tmp.substring(0, tmp.indexOf("."))); // filename body part
        } catch(someError) {
            exportInfo.destination = new String(exportPath);
            exportInfo.fileNamePrefix = app.activeDocument.name; // filename body part
    // Function: saveFile
    // Usage: the worker routine, take our params and save the file accordingly
    // Input: reference to the document, the name of the output file,
    //        export info object containing more information
    // Return: <none>, a file on disk
    function saveFile( docRef, fileNameBody, exportInfo) {
                saveFile(docRef, fileNameBody, exportInfo, false, true);
                function saveFile( docRef, fileNameBody, exportInfo, interlacedValue, transparencyValue) {
                var id6 = charIDToTypeID( "Expr" );
                    var desc3 = new ActionDescriptor();
                    var id7 = charIDToTypeID( "Usng" );
                        var desc4 = new ActionDescriptor();
                        var id8 = charIDToTypeID( "Op  " );
                        var id9 = charIDToTypeID( "SWOp" );
                        var id10 = charIDToTypeID( "OpSa" );
                        desc4.putEnumerated( id8, id9, id10 );
                        var id11 = charIDToTypeID( "Fmt " );
                        var id12 = charIDToTypeID( "IRFm" );
                        var id13 = charIDToTypeID( "PN24" );
                        desc4.putEnumerated( id11, id12, id13 );
                        var id14 = charIDToTypeID( "Intr" );
                        desc4.putBoolean( id14, interlacedValue );
                        var id15 = charIDToTypeID( "Trns" );
                        desc4.putBoolean( id15, transparencyValue );
                        var id16 = charIDToTypeID( "Mtt " );
                        desc4.putBoolean( id16, true );
                        var id17 = charIDToTypeID( "MttR" );
                        desc4.putInteger( id17, 255 );
                        var id18 = charIDToTypeID( "MttG" );
                        desc4.putInteger( id18, 255 );
                        var id19 = charIDToTypeID( "MttB" );
                        desc4.putInteger( id19, 255 );
                        var id20 = charIDToTypeID( "SHTM" );
                        desc4.putBoolean( id20, false );
                        var id21 = charIDToTypeID( "SImg" );
                        desc4.putBoolean( id21, true );
                        var id22 = charIDToTypeID( "SSSO" );
                        desc4.putBoolean( id22, false );
                        var id23 = charIDToTypeID( "SSLt" );
                            var list1 = new ActionList();
                        desc4.putList( id23, list1 );
                        var id24 = charIDToTypeID( "DIDr" );
                        desc4.putBoolean( id24, false );
                        var id25 = charIDToTypeID( "In  " );
                        desc4.putPath( id25, new File( exportPath + "C:/Users/Tim/Desktop/Backdrops/png/"  + fileNameBody + ".png") );
                    var id26 = stringIDToTypeID( "SaveForWeb" );
                    desc3.putObject( id7, id26, desc4 );
                executeAction( id6, desc3, DialogModes.NO );
    // Function: zeroSuppress
    // Usage: return a string padded to digit(s)
    // Input: num to convert, digit count needed
    // Return: string padded to digit length
    function zeroSuppress (num, digit) {
        var tmp = num.toString();
        while (tmp.length < digit) {
            tmp = "0" + tmp;
        return tmp;
    // Function: setInvisibleAllArtLayers
    // Usage: unlock and make invisible all art layers, recursively
    // Input: document or layerset
    // Return: all art layers are unlocked and invisible
    function setInvisibleAllArtLayers(obj) {
        for( var i = 0; i < obj.artLayers.length; i++) {
            obj.artLayers[i].allLocked = false;
            obj.artLayers[i].visible = false;
        for( var i = 0; i < obj.layerSets.length; i++) {
            setInvisibleAllArtLayers(obj.layerSets[i]);
    // Function: removeAllInvisibleArtLayers
    // Usage: remove all the invisible art layers, recursively
    // Input: document or layer set
    // Return: <none>, all layers that were invisible are now gone
    function removeAllInvisibleArtLayers(obj) {
        for( var i = obj.artLayers.length-1; 0 <= i; i--) {
            try {
                if(!obj.artLayers[i].visible) {
                    obj.artLayers[i].remove();
            catch (e) {
        for( var i = obj.layerSets.length-1; 0 <= i; i--) {
            removeAllInvisibleArtLayers(obj.layerSets[i]);
    // Function: removeAllEmptyLayerSets
    // Usage: find all empty layer sets and remove them, recursively
    // Input: document or layer set
    // Return: empty layer sets are now gone
    function removeAllEmptyLayerSets(obj) {
        var foundEmpty = true;
        for( var i = obj.layerSets.length-1; 0 <= i; i--) {
            if( removeAllEmptyLayerSets(obj.layerSets[i])) {
                obj.layerSets[i].remove();
            } else {
                foundEmpty = false;
        if (obj.artLayers.length > 0) {
            foundEmpty = false;
        return foundEmpty;
    // Function: zeroSuppress
    // Usage: return a string padded to digit(s)
    // Input: num to convert, digit count needed
    // Return: string padded to digit length
    function removeAllInvisible(docRef) {
        removeAllInvisibleArtLayers(docRef);
        removeAllEmptyLayerSets(docRef);
    // Function: exportChildren
    // Usage: find all the children in this document to save
    // Input: duplicate document, original document, export info,
    //        reference to document, starting file name
    // Return: <none>, documents are saved accordingly
    function exportChildren(dupObj, orgObj, exportInfo, dupDocRef, fileNamePrefix) {
        for( var i = 0; i < dupObj.artLayers.length; i++) {
            if (exportInfo.visibleOnly) { // visible layer only
                if (!orgObj.artLayers[i].visible) {
                    continue;
            dupObj.artLayers[i].visible = true;
            var layerName = dupObj.artLayers[i].name;  // store layer name before change doc
            var duppedDocumentTmp = dupDocRef.duplicate();
            if ((png24Index == exportInfo.fileType)||(png8Index == exportInfo.fileType)) { // PSD: Keep transparency
                removeAllInvisible(duppedDocumentTmp);
                //PNGFileOptions
                        if (activeDocument.activeLayer.isBackgroundLayer == false) { //is it anything but a background layer?
                            app.activeDocument.trim(TrimType.TRANSPARENT);
            } else { // just flatten
                duppedDocumentTmp.flatten();
            // Edit
            var docName = app.activeDocument.name;
            // For some reason indexOf fails if we include the '-', so we use 'copy' and decrement the index by 1.
            docName = docName.slice(0, docName.indexOf('copy')-1);
            var fileNameBody = (docName+'_'+layerName).toLowerCase();
            fileNameBody = fileNameBody.replace(/[:\/\\*\?\"\<\>\|]/g, "_");  // '/\:*?"<>|' -> '_'
            if (fileNameBody.length > 120) {
                fileNameBody = fileNameBody.substring(0,120);
            saveFile(duppedDocumentTmp, fileNameBody, exportInfo);
            duppedDocumentTmp.close(SaveOptions.DONOTSAVECHANGES);
            dupObj.artLayers[i].visible = false;
        for( var i = 0; i < dupObj.layerSets.length; i++) {
            if (exportInfo.visibleOnly) { // visible layer only
                if (!orgObj.layerSets[i].visible) {
                    continue;
            var fileNameBody = fileNamePrefix;
            fileNameBody += "_" + zeroSuppress(i, 4) + "s";
            exportChildren(dupObj.layerSets[i], orgObj.layerSets[i], exportInfo, dupDocRef, fileNameBody);  // recursive call
    // Function: objectToDescriptor
    // Usage: create an ActionDescriptor from a JavaScript Object
    // Input: JavaScript Object (o)
    //        object unique string (s)
    //        Pre process converter (f)
    // Return: ActionDescriptor
    // NOTE: Only boolean, string, number and UnitValue are supported, use a pre processor
    //       to convert (f) other types to one of these forms.
    // REUSE: This routine is used in other scripts. Please update those if you
    //        modify. I am not using include or eval statements as I want these
    //        scripts self contained.
    function objectToDescriptor (o, s, f) {
        o = {};
        var d = new ActionDescriptor;
        var l = o.reflect.properties.length;
        d.putString( app.charIDToTypeID( 'Msge' ), s );
        for (var i = 0; i < l; i++ ) {
            var k = o.reflect.properties[i].toString();
            if (k == "__proto__" || k == "__count__" || k == "__class__" || k == "reflect")
                continue;
            var v = o[ k ];
            k = app.stringIDToTypeID(k);
            switch ( typeof(v) ) {
                case "boolean":
                    d.putBoolean(k, v);
                    break;
                case "string":
                    d.putString(k, v);
                    break;
                case "number":
                    d.putDouble(k, v);
                    break;
                default:
                    if ( v instanceof UnitValue ) {
                        var uc = new Object;
                        uc["px"] = charIDToTypeID("#Rlt"); // unitDistance
                        uc["%"] = charIDToTypeID("#Prc"); // unitPercent
                        d.putUnitDouble(k, uc[v.type], v.value);
                    } else {
                        throw( new Error("Unsupported type in objectToDescriptor " + typeof(v) ) );
        return d;
    // Function: descriptorToObject
    // Usage: update a JavaScript Object from an ActionDescriptor
    // Input: JavaScript Object (o), current object to update (output)
    //        Photoshop ActionDescriptor (d), descriptor to pull new params for object from
    //        object unique string (s)
    //        JavaScript Function (f), post process converter utility to convert
    // Return: Nothing, update is applied to passed in JavaScript Object (o)
    // NOTE: Only boolean, string, number and UnitValue are supported, use a post processor
    //       to convert (f) other types to one of these forms.
    // REUSE: This routine is used in other scripts. Please update those if you
    //        modify. I am not using include or eval statements as I want these
    //        scripts self contained.
    function descriptorToObject (o, d, s, f) {
        var l = d.count;
        if (l) {
            var keyMessage = app.charIDToTypeID( 'Msge' );
            if ( d.hasKey(keyMessage) && ( s != d.getString(keyMessage) )) return;
        for (var i = 0; i < l; i++ ) {
            var k = d.getKey(i); // i + 1 ?
            var t = d.getType(k);
            strk = app.typeIDToStringID(k);
            switch (t) {
                case DescValueType.BOOLEANTYPE:
                    o[strk] = d.getBoolean(k);
                    break;
                case DescValueType.STRINGTYPE:
                    o[strk] = d.getString(k);
                    break;
                case DescValueType.DOUBLETYPE:
                    o[strk] = d.getDouble(k);
                    break;
                case DescValueType.UNITDOUBLE:
                    var uc = new Object;
                    uc[charIDToTypeID("#Rlt")] = "px"; // unitDistance
                    uc[charIDToTypeID("#Prc")] = "%"; // unitPercent
                    uc[charIDToTypeID("#Pxl")] = "px"; // unitPixels
                    var ut = d.getUnitDoubleType(k);
                    var uv = d.getUnitDoubleValue(k);
                    o[strk] = new UnitValue( uv, uc[ut] );
                    break;
                case DescValueType.INTEGERTYPE:
                case DescValueType.ALIASTYPE:
                case DescValueType.CLASSTYPE:
                case DescValueType.ENUMERATEDTYPE:
                case DescValueType.LISTTYPE:
                case DescValueType.OBJECTTYPE:
                case DescValueType.RAWTYPE:
                case DescValueType.REFERENCETYPE:
                default:
                    throw( new Error("Unsupported type in descriptorToObject " + t ) );
        if (undefined != f) {
            o = f(o);
    // Function: preProcessExportInfo
    // Usage: convert Photoshop enums to strings for storage
    // Input: JavaScript Object of my params for this script
    // Return: JavaScript Object with objects converted for storage
    function preProcessExportInfo(o) {
        o.tiffCompression = o.tiffCompression.toString();
        o.pdfEncoding = o.pdfEncoding.toString();
        o.targaDepth = o.targaDepth.toString();
        o.bmpDepth = o.bmpDepth.toString();
        return o;
    // Function: postProcessExportInfo
    // Usage: convert strings from storage to Photoshop enums
    // Input: JavaScript Object of my params in string form
    // Return: JavaScript Object with objects in enum form
    function postProcessExportInfo(o) {
        o.tiffCompression = eval(o.tiffCompression);
        o.pdfEncoding = eval(o.pdfEncoding);
        o.targaDepth = eval(o.targaDepth);
        o.bmpDepth = eval(o.bmpDepth);
        return o;
    // Function: StrToIntWithDefault
    // Usage: convert a string to a number, first stripping all characters
    // Input: string and a default number
    // Return: a number
    function StrToIntWithDefault( s, n ) {
        var onlyNumbers = /[^0-9]/g;
        var t = s.replace( onlyNumbers, "" );
        t = parseInt( t );
        if ( ! isNaN( t ) ) {
            n = t;
        return n;
    // End X2L.jsx

  • Add layers from other psd file and retain text layers (Batch processing)

    I want to batch process a large number of portraits adding text info from the filename (year_name_number.jpg) to existing text layers. I want to make a template psd file containg the correct labeled text layers formatted and adjusted (With bleding effects and more) How can i add layers from an other psd file to the active document and retaining the text layers editable. The place command in PS5 adds the file as a smart object, no use.
    Any ideas?
    I tried the combined action/script way, but no joy so far. Right now i am making the text layers with a action, then calling the script from the action. It works but its difficult to make different templates from adjusting a action.
    The code i am using now (in combination with a action creating the 3 text layers and other grapchical elements)
    var docRef = activeDocument;
    // strip the extension off
    var fileNameNoExtension = docRef.name;
    fileNameNoExtension = fileNameNoExtension.split( "_" );
    if ( fileNameNoExtension.length > 1 ) {
                    fileNameNoExtension.length--;
    fileNameNoExtension = fileNameNoExtension.join("_");
    var myString = fileNameNoExtension;
    var mySplitResult = myString.split("_");
    var textLayer = docReflayers['Year']; // define the existing text layer to a var
    docRef.activeLayer = textLayer;
    textLayer.kind = LayerKind.TEXT;
    var T1 = textLayer.textItem;
    T1.contents = mySplitResult[0]
    var textLayer = docRef.layers['Name']; // define the existing text layer to a var
    docRef.activeLayer = textLayer;
    textLayer.kind = LayerKind.TEXT;
    var T2 = textLayer.textItem;
    T2.contents = mySplitResult[1]
    var textLayer = docRef.layers['Number']; // define the existing text layer to a var
    docRef.activeLayer = textLayer;
    textLayer.kind = LayerKind.TEXT;
    var T3 = textLayer.textItem;
    T3.contents = mySplitResult[2]
    Thanks
    Eivind

    norway_photo wrote:
    Here is my intended workflow:
    - A set of same size portraits labeled "year_name_number.jpg"
    - A template.psd os same size with graphical elements and text layers (named "year", "name" and "number")
    - A script or action copy/pasting og adding all layers from the template.psd file to the open portrait file, retaining text layers editable.
    - A script (The one i have working) changing the text layers added from the template to text from the filename.
    - A action saving this as a PDF ready for print.
    This way i can process a large number of portraits, add names and other information and save it as a file ready for print.
    I can image it is much easier to edit a template than writing a script or an action creating all the graphical elements.
    And even better, to change this template for different customers/departments/logos.
    Basically i need a way to add layers to an open file using a batch file or script.
    Eivind
    OK I understand what your trying to do and now I do not agree with your conclusion you made in you first append about place being no good for you.  Its is I think a perfect solution for you. I feel you need to address the process from a new angle.
    I am very familiar with templates I use them all the time for collages which I populate with an actions.  However I do not batch this process and my process is interactive.  If you look at what your trying to do from the angle of creating a collage.  You will see what you are trying to do is automate the population of a single image collage using a single template in a batch process.  An example of one of my single image collage populated by one of my actions that has been saved as a jpeg image file.  My actions are played in Photoshop with no document opened.  After my action is play there is a single collage document in Photoshop that contains layers that can be tweaked all text is in text layers the can be edited.
    If I wanted to automate the batch population of a single collage template I think all I would need to know is three thing.
    1.) The location of the input images
    2.) The full Path of the PSD template file.
    3.) The location to store the output  file
    Looking at some of the recent threads in this forum I could almost cut and past the script you want to put  together.  There was a recent thread that had javascript code to process files in a folder and process only a list of file types.   There also was a thread that had a place function in it to place images into the current document or create a new document to place the image into.  The image was read from the web using a URL.  This thread has code to change a text layer.  At first I though you may need to open these image file to get at its meta-data to get the Portrait image Exif creation data.  But see all you need is the Filename for it has the data you want the year and name.  So the function that get the image files from the folder will give you that. The   Script needs to Open the Template PSD file and retrieve the prototype text layers text content  then the scrip needs a loop that get the next image file to be processed from the folder get filename function. In the loop the image files are place into the open template above a place holder layer like the Background layer. Then using the prototype text contents and the filename are used  create the new content for the text layer and then change the text layers content to it.  Follow that up with a save as for the output file.  Once the output file is saved delete the placed smart object layer.  When this loop ends the script will close the document with no save and end. As for the three inputs you need  the script could either have a dialog like the images processor or simply prompt you for the folders and template file.

  • Complicated question: dialog box-batch processing script

    I am adapting the working script I found on this forum.
    Script: Open files as layers in Photoshop
    https://forums.adobe.com/thread/1313579
    The goal of the adaptation is to include a javascript Folder dialog to set the save folder destination at run time and
    use this folder destination for the remaining script batch processing functions.
    Presently, the script loads a Bridge stack as Photoshop layers and saves the layered tiff using the Folder dialog.
    The folder dialog is manifesting every time the script encounters a Bridge stack.
    The question is what is the correct script logic to set the destination folder once at run time and keep this destination
    folder for the stack batch processing.
    #target bridge
    var stacks = app.document.stacks;
    var stackCount = stacks.length;
    for(var s = 0;s<stackCount;s++){
          var stackFiles = getStackFiles( stacks[s] );
          if(stackFiles.length> 1){
               var bt = new BridgeTalk;
               bt.target = "photoshop";
               var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+stackFiles.toSource()+");");
               bt.body = myScript;
               bt.send(5);
    function getStackFiles( stack ){
          var files = new Array();
          for( var f = 0; f<stack.thumbnails.length;f++){
               files.push(stack.thumbnails[f].spec);
          return files;
    function psRemote(stackFiles){
    app.bringToFront();
    var thisDoc = open(File(stackFiles[0]));
    var Name = decodeURI(app.activeDocument.name).slice(0,-4);
    thisDoc.layers[0].name = decodeURI(Name);
    for(var a = 1;a<stackFiles.length;a++){
        open(File(stackFiles[a]));
        Name = decodeURI(app.activeDocument.name).slice(0,-4);
        activeDocument.activeLayer.duplicate(thisDoc);
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        thisDoc.layers[0].name = Name;
    var tifOptions = new TiffSaveOptions();
    tifOptions = new TiffSaveOptions();
    tifOptions.embedColorProfile = true;
    tifOptions.imageCompression = TIFFEncoding.TIFFLZW;
    tifOptions.alphaChannels = false;
    tifOptions.byteOrder = ByteOrder.MACOS;
    tifOptions.layers = true;
    var theFolder = Folder.selectDialog ("Select Folder");
    if (theFolder) {
            var myFile = new File( theFolder + "/" + app.activeDocument.name);
            app.activeDocument.saveAs(myFile, tifOptions, true);  
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

    I am thinking the Folder dialog is not correct for this application.
    On a second thought a persistent dialog to set the save folder path and run the script from the persistent dialog can make sense.
    Any ideas?

  • How batch export layers to files in CS5

    Hi,
    I am a newbie in CS5 , I tried to batch export layer to files in CS5 , because I have thousands  PSD files that I need to export layers in  separated png files..
    In each script I made I have the following error.." reference error: dlgMain is not found" ( in french: erreur de reference: dlgMain n'est pas definie)
    How  can I batch export layers to files in CS5??
    Thankyou all by advance for your help.

    I am humbled to be of any help. I truly believe you are one of the unsung heroes of the Photoshop community!
    I lost track of how many custom and ingenious scripts you created for countless other users, in so many online places...
    As a scripts Illiterate, I bow in front of your knowledge and generosity!
    (But Learning After Effects Expressions might in fact made me begin to make tiny steps towards wrapping my head around scripting)

  • Bridge batch processing script for Photoshop stops after ten mins

    I have a javacript to help batch process collections of images in Bridge by sending them (in layers) to Photoshop CS5. It works perfectly, except it stops running after about ten minutes (around 6-10 images) so that I have to keep restarting the script. This behaviour has only started since the script was installed in the Bridge startup folder so that it could be started from the (right click) menu. The script does not seem to time out when run via ExtendToolkit.
    Does anyone know why this is happening?

    Thanks again Paul. Can I ask you where the best place to insert that would be? The script is below - I'm sure you'll recognise it :6).
    I've also been wondering if its possible to alter the script so that the files in bridge are opened in PS as Smart Objects (in layers)? There is a script 'Open as Smart Object in Layers' but I haven't been able integrate it into your fantastic script.
    #target bridge
    if( BridgeTalk.appName == "bridge" ) {
    processDocs = new MenuElement("command", "Process selected docs", "at the end of Thumbnail");
    processDocs.onSelect = function () {
    var sels = app.document.selections;
    var selectedFiles = new Array();
    for(var a in sels){
        selectedFiles.push(sels[a].spec);
          if(selectedFiles.length> 1){
               var bt = new BridgeTalk;
               bt.target = "photoshop";
               var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+selectedFiles.toSource()+");");
               bt.body = myScript;
               bt.send(5);
    function psRemote(selectedFiles){
    app.bringToFront();
    for(var f in selectedFiles){
    var thisDoc = open(File(selectedFiles[f]));
    /*run an action if required */
    /* app.doAction("atn", "atnSet"); */
    /*script listener code goes here...
      You will need to remove the //===== lines or the script will fail 
    /* end script listener code */
          var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');
          app.activeDocument.saveAs(saveFile);
          app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

  • Batch processing with a re-save Script

    i have a script that i use to re-save a master file that may or may not have many layers, channels and/or paths.  when i have the master file open, i run the script and it flattens the image, deletes all the channels and paths, and then does a "save as" step saving the file as a tiff with lzw compression.  this all takes place without any user input or dialogs.  the script is copied at the bottom for reference.   i have made an action out of this script and it works fine everytime.  the problem is that when i try to batch process multiple file with this action, it seems that regardless of which options i choose in the batch processing window for saving (e.g. "none", save and close", etc.), the action is interrupted with the usual "save as" dialog window and even though lzw is specified in the script, i also have to manually select this option in the dialog.  does anyone know how to accomplish what i am trying to do (batch "save as" with lzw compression to files that are saved as uncompresseed tiffs) without having to stop for any dialogs?  please help!!!!  thanks.
    johnh h.
    if(documents.length){
    var saveFile = new File(activeDocument.fullName.fsName);
    SaveTIFF(saveFile);
    function SaveTIFF(saveFile){
        tiffSaveOptions = new TiffSaveOptions();
        tiffSaveOptions.embedColorProfile = true;
        tiffSaveOptions.alphaChannels = true;
        tiffSaveOptions.byteOrder = ByteOrder.IBM;
        tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
        activeDocument.saveAs(saveFile, tiffSaveOptions, false, Extension.LOWERCASE);
        activeDocument.close();

    hey michael,
    your reply made me curious to try something i hadn't tried before which was to run the "batch" processing from within photoshop and to my surprise it worked.  however if i repeat the exact same thing from within bridge (although in bridge i am selecting multiple files instead of the enclosing folder) it runs into the same problem.  so you have 1/2 solved my problem.  did you actually get it to run properly from bridge (bridge/tools/photoshop/batch) or did you run it from within photoshop itself?  please let me know... i am very curious to detmine the source of the problem.  thanks.  i appreciate the help.

  • How to use a custom script in a batch process?

    I was recently told that I can Photomerge, crop and save 2 separate folders of images to a 3rd folder in a batch process if I created a custom Javascript.  Are there any examples of how to integrate a custom script as an action in a batch process?

    if you recieve an image from mms you can save the object to gallery and then select it as wallpaper
    If  i have helped at all a click on the white star below would be nice thanks.
    Now using the Lumia 1520

Maybe you are looking for

  • X not starting on new installation

    Hello all! today I decided to try arch for the first time. THe installation went well, but now i cannot get x to start. I have read through most of the xorg wiki and cannot find a way to solve my problem. Here is the crash log: http://bpaste.net/show

  • Error when generating FIFO reports

    Dear SAP Guru's, I have configured Balancesheet valuation procedures, I am getting the following error when running MRF1 "For material XX no FIFO results exist in Company Code XX01 for method FIF05" error message number is MY 261.

  • SAP* locked!Unlocking from DB level says unknown table USR02

    Hi, The user SAP* is locked. I tried to unlock it at DB(MAXDB) by query: sql_execute update <db_schema>.USR02 set UFLAG=0 where BNAME='SAP*' and MANDT=u2019000u2019 It says: ERR -24988,ERR_SQL: SQL error -4004,Unknown table name:USR02 Anything can be

  • FM CCARD_ENVELOPE SSF Error: Unknown error in external security prod

    Hi all, Im still new in SAP. I am trying to run function module CCARD_ENVELOPE to encrypt a credit card number in tcode se37. After i input the credit card number and run it,it shows me an error ENVELOPE_FAILED, Error when encrypting payment card dat

  • 24 FPS Capture Question

    HI I am trying to capture some 24 frames per second footage I filmed on a Panasonic DVX100 and one of the Final Cut Pro capture settings is for the 2:3:3:2 advnaced pulldown removal for 24fps. However, in the summary, it has the frames per second lis