Batch trimming/bounce

Hi,
I have around 240 audio files that are around 31 seconds each. I now want to create a 10-15 second version of each file and can't think of a quick and easy way to do this without bouncing down every file again. I want to trim each file at exactly the same point and the only ways I can think of doing this are:
1. Selecting each file in the audio window and trimming them at the same points.
or
2. Putting the files onto an individual audio track, selecting the bounce function and then entering the start and end points in the bounce dialog window.
However, the number of audio tracks available to me is much lower than 240 - and either way I would have my work cut out doing every track individually.
Any ideas would be greatly appreciated,
Jack

Well, the cutting process was explained so it could be done in, like, 2 minutes.
To answer your question, A procedure such as this could be done by creating a simple macro of Key Commands which could:
step to next region
switch to the sample editor
perform the fade
switch back to the arrange
Repeat 240 times
If you had no batch processor, it could be done almost as easily ( and almost as quickly ) as using a batch processor. Of course, Accelerando integrates with several components of your OS and other applications, including Peak Pro and Sample Manager - both of which have very good Batch capabilities.
J

Similar Messages

  • Batch trimming video

    Hi there - this is probably a unique problem but thought I'd pose the question.  If someone wanted to batch export a large quantity of clips, but change the in/out point for each clip, is that possible?  For instance, say I was given 400 pieces of prores video.  For reasons not worth mentioning, the first 4 seconds and the last 4 seconds need to be trimmed out.  No other edits are needed on these clips but going through all 400 and doing this manually will really suck. 
    Food for thought.  If anyone knows a solution to this, please share.  I have not found this function in Adobe Media Encoder or any other product for that matter. 
    Thanks!
    EW

    None that I'm aware of. Certainly not in Premiere Elements.
    The nature off video is that it's added to a project, effects are added to it and then a new video is output. (Unlike photos, in which the original files are changed.) Because of that nature, batch changing video clips isn't really available -- even with a high-end program like After Effects.

  • Trimmed podcasts play correctly in iTunes but not on ipod shuffle

    There's some short podcasts from NPR that have commercials at both the beginning and end. They're almost as long as the main content. I've been able to use the "Batch Trim Start or Stop Time (Seconds)" script from Doug's Applescripts for Itunes website to trim 15-20 seconds off the start and stop times. It works when I play them in iTunes, the podcasts start and stop exactly where they're set. But if I sync these trimmed podcasts to my iPod Shuffle then either the start or end time is ignored, or the podcast just abruptly ends in the middle.
    Any ideas what's happening?

    Anyone know why the start and stop times aren't respected on the ipod but are in iTunes when using the batch trim script?

  • I want a Batch Processing feature!

    I have soundbooth CS3 - but i REALLY need a batchprocessing feature. canty find it in CS3, will it be in CS4?
    Specifically i need:
    1) batch normalization
    2) batch trim (begining and end)
    3) batch file format conversion

    Hi,
    Soundbooth CS4 doesn't yet have dedicated Batch processing functionality, however it does offer Batch Volume Equalization and Matching. Adobe Audition does offer comprehensive batch processing which can address all the needs you've listed.
    Durin

  • Batch crop pdfs to the trim size

    I have hundreds of pdfs that include all printer marks (crop marks, color guide..etc..) and i want trim or crop these pdfs in order to remove these marks.  I want to end up with just the artwork itself with no printer marks. I also don't want to import into photoshop which will rasterize the content.  Surely, there must be an easy way inside Acrobat Pro to do this?  Haven't found it, though.  The crop tool just baffles me.  I know that in Acrobat Pro I can use the crop tool and draw a rectangle to crop to but what i want is to automatically crop to the trim marks or the artboard and then set it up as a batch.  Thanks for listening.
    -Mark

    Which version of Acrobat are you using? If 9 then there's no Crop Pages options anymore in the batch sequences. You will need a custom-made script to do it, like this one: http://try67.blogspot.com/2009/02/acrobat-batch-crop-pages.html
    Contact me by email if you're interested in it.  Otherwise you can just use the built-in function to crop the pages of multiple files.

  • Is it possible to batch bounce audio files from markers?

    Archiving old DAT tapes, I'm wondering if it's possible to create and even name markers on the fly and later "batch bounce" the whole tape offline to audio files bearing the same name as the markers.
    I'm aware that you can split regions & batch bounce them but AFAIK you can't split a region on the fly...
    I'm using Logic 9 yet but if what I'm asking is only possible in X I'm ready to take the plunge, it would be a big time saver
    Thank you for any help

    BTW is it possible to recover the start IDs from the DAT while recording it in Logic ?

  • How to batch convert pdf to jpgs, crop to trim and save?

    I'm trying to figure out how to take a couple of hundred PDFs, Crop them to trim, then convert them all to JPGs using any of the adobe programs.
    In bridge I was able to Batch convert all the PDFs to JPGs but it wouldn't crop them to the trim also...
    I thought I could use the Photoshop Image Processor to batch action crop and save them again but I always get one of two errors... "There were no source files that could be opened by Photoshop." or "Please Specify a destination folder."
    I don't know why this is coming up since I have it selecting the folders with the JPGs that I converted in Bridge and saving to another folder..
    Does anyone know if I can do all of this at once? Or how I can somehow get this to work so that II don't have to open,crop and save for each individual file?

    Corel's WP has not / does not use anything of Adobe's to create PDFs.
    With Acrobat installed you can "file - print" WP files to the Adobe PDF virtual printer that is installed with Acrobat.
    Perhaps an OS based "batch" printer job would be possible. Something for you to look into.
    As well, if you have WP installed there may be something WP can do.
    To learn of such you'd want to visit Corel's WP customer support.
    Be well...

  • Bouncing Apache service through schedule batch script

    Hi
    We are using Oracle11i(11.5.10.2) with Database version 10.2.0.3 on windows 2000 server.
    We are getting login page error frequently for temporary solution we are bouncing apache service frequently.
    Now i want to restart Apache service through schedule batch script ,is it possible?
    Thanks
    With Regards
    Umair

    Hi Husseinr,
    Use Windows Task Scheduler to accomplish this.
    there is no diect option to schedule the service to restart and Actually i don't have batch script to schedule through Task Scheduler.
    Why don't you try to fix the issue instead of bouncing Apache? Did you log a SR?
    We raised SR and We are Following SR also it is has been running for long time,so until SR Solution i want to bounce the Apache servie through Scheduled Batch Script.
    Thanks
    Umair

  • Executing batch file from Java stored procedure hang

    Dears,
    I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
    public static String runFile(String drive)
    String result = "";
    String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
    try {
    File directory = new File(drive + ":");
    File file = File.createTempFile("bb1", ".bat", directory);
    file.deleteOnExit();
    FileWriter fw = new java.io.FileWriter(file);
    fw.write(content);
    fw.close();
    // The next line is the command causing the problem
    Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = input.readLine()) != null)
    result += line;
    input.close();
    file.delete();
    result = result.substring( result.lastIndexOf( ' ' )).trim();
    } catch (Exception e) {
    e.printStackTrace();
    result = e.getClass().getName() + " : " + e.getMessage();
    return result;
    The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
    I gave the SYSTEM schema the required privilege to execute the code.
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    GRANT JAVAUSERPRIV TO SYSTEM;
    I have used the following to load the class in Oracle 9ir2 DB:
    loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
    CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
    I have seen similar problems on other forums, but no solution posted
    [http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
    I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
    Can anyne help?

    Dear Peter,
    You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
    I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
    The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
    The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
    where content of bb1.bat as follows:
    echo off
    vol C: | find /i "Serial Number is"
    The above batch file just get the serial number of hard drive assigned when windows formatted HD.
    Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    Never returns
    Thanks for tracing teh issue to that details ;) hope you coul help.

  • Problem with Ultrabeat and Bounce in Place

    Hi,
    I'm new here and reasonably new to Logic as I have been an Ableton user for quite a few years. I was eventually enticed by Logic Express 9 due to the fantastic price and the features on offer.
    Anyway on to my problem! I have been getting my head around Ultrabeat and using multiple outputs. I discovered the Bounce in Place command for tracks and regions which is an amazing time saver. However I am noticing that when I use this command, the audio that is produced is not quite in line with the grid. Its clear to see the blank space at the start of the audio file.
    Obviously I can trim the audio down but I'm sure i shouldn't have to. I was wondering if this is either a bug or whether I am missing something?
    By the way I am using Logic Express 9.1.3 and Snow Leopard.
    Any help would be greatly appreciated.
    Cheers
    Any help would be greatly appreciated

    Hi,
    how do you trigger UB? Do you use pattern mode or do you use standard MIDI events?
    I cannot reproduce the problem.
    Fox

  • How to get unique Batch Name for AP Open Interface Import Program

    Hi,
    We have enabled the invoice batch controls i.e. the profile option 'AP: Use Invoice Batch Controls' set to Yes.
    We have an interface with some system from where we receive a data file that has AP invoices. The invoices are loaded into staging table, and finally into AP invoice interface tables. After this the AP Open interface import is run.
    The relevant programs are in a concurrent request set and are executed every day.
    The issue is with the 'Batch Number' parameter of the Payables Open Interface Import Program. If I enter some text as the batch number, the Batch gets created with that name only. As such we need the Batch number to be unique for each job run.
    Oracle help says "If the AP: Use Invoice Batch Controls profile option is enabled and if you provide no value for this parameter then the system provides a value for you. The value the system provides is the concatenation of the Source and a unique sequential number. For example, ERS: 1234".
    However the problem is the Batch Name Parameter is mandatory, and cannot be left NULL.
    Has any one faced this issue earlier? Am I missing any setup or step?
    Any inputs in this regard would be highly appreciated!
    Best regards,
    Anand

    The proper Oracle suggested method would be to put a wrapper program around your request set that determines the batch name.
    The easier (abet less supported) method:
    CREATE OR REPLACE TRIGGER custom.coop_ap_batches_all_insert
    BEFORE
    INSERT
    ON ap.ap_batches_all
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    BEGIN
    -- to update batch name...
    -- created so that the nightly batches can have unique names by date
    -- nightly batches will be created with their simple name
    -- IE VIR, DI, MI, etc... this trigger will rename them
    -- to YYYY-MM-DD-VIR, YYYY-MM-DD-DI, YYYY-MM-DD-MI, etc...
    IF LENGTH(TRIM(:new.batch_name)) < 4 THEN
    :new.batch_name := TO_CHAR(SYSDATE,'YYYY-MM-DD') || '-' || :new.batch_name;
    END IF;
    :new.batch_name := UPPER(:new.batch_name);
    END;
    /

  • Windows bactch job to trim the Listener log

    Hi All ,
    Can you help me to write a Windows batch job to trim the listener.log on periodically.
    I have the below steps, which i do manually but i won't which needs to be put in batch.
    copy listener.log listener_<today>.log
    lsnrctl set log_file listener_new.log
    del listener.log
    lsnrctl set log_file listener.log
    lsnrctl reload
    del listener_new.log
    Appriciate the Help.
    Thanks in Advance.

    Have a look here:
    http://www.wikihow.com/Write-a-Batch-File
    You have the commands, so you only need the batch file around it
    HTH
    FJFranken

  • Batch consolidate and vprs

    Hi, Need some advise from some SAP guru. In our current system, we already setup the batch management. When perform delivery and billing, most model ship- out, will using more than one batch.
    Case:
         Model A
         Sales Price => 6.05
         Standard Cost => 4.00
    The PGI [vl02n] will result to create of two material document (601) and also posting to FI-GINI account.
    <u>Batch | Qty     | Price     | Amount</u>
    aaa      | 33     | 4.05     | 13.37
    bbb     | 67     | 4.05     | 27.14
    Total      40.51
    The billing [vf01], will copy the delivery information as seperate batch and this will be use as to calculate the total invoice. Posting to FI-GINI will also be occur.
    <u>Batch | Qty | Price | Amount  | Cost (VPRS) | Cost Amt</u>
    aaa    | 33   | 6.05  | 19.97      | 4.05             | 13.37
    bbb    | 67   | 6.05  | 40.54      | 4.05             | 27.14
    Total 60.51----
    40.51
    In Invoice printing, we only print out one record as we already add-out the batch qty as total.
    Model       |Qty | Price |     Amount
    Model A  |100 | 6.05  | 60.51
    PROBLEM : So now, the problem will be customer ask the 100x6.05 => should be 60.50. Not 60.51.
    Last time, we configure to accumulate the batch qty to item total. The result look promising. But problem occur on the FI-GINI account.
    1. Billing qty set to 'H' in VTFL for batch and total item.
    2. IMG > Sales & Dist > Sales > Sales Document Item > Define Item Category. Statistical value set to 'X' for batch item.
    The PGI [vl02n] will still result to create of two material document (601) and also posting to FI-GINI account.
    <u>Batch | Qty | Price |Amount</u>
    aaa   | 33  | 4.05  | 13.37
    bbb   | 67  | 4.05  | 27.14
    Total 40.51
    The billing [vf01], will accumulate the delivery information as one total item and this will be use as to calculate the total invoice. Posting to FI-GINI will also be occur.
    <u>Qty | Price | Amount | Cost (VPRS) | Cost Amt</u>               
    100 | 6.05 | 60.50 | 4.05 | 40.50
    In Invoice printing, only print out one record follow to vf01.
    <u>Model |Qty | Price | Amount</u>
    Model A | 100 | 6.05 | 60.50
    Invoice to customer OK.
    PROBLEM : GINI account during PGI will be 40.51 but during billing will be 40.50. So debit and credit will be 0.01 diff.
    Any help on what I may need to do?<u></u>

    thanks.  That worked. Although I still don't know why when I consolidate
    and transcode, it doesn't trim my master file down smaller (I have a 6 GB
    quicktime in my sequence, but with all my trims, I'm only using less than
    half of that quicktime in my sequence - yet it still insists on copying
    over the entire 6gb file, rather than trimming it down to only the parts
    that I used in the final cut (it just makes me have to send more than I
    need to my colorist - therefore making it a painfully slow upload process)
    On Thu, Apr 23, 2015 at 11:17 AM, Trent Happel <[email protected]>

  • Cannot add row without complete selection of batch/serial numbers while creating Goods receipt purchase order

    Error:Cannot add row without complete selection of batch/serial numbers
           Dim oPDN As SAPbobsCOM.Documents
           oPDN = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes)
                         Dim serno As String = "SH-A1,SH-A2"
                        Dim sernoval As String() = serno.Split(",")
                        Dim mnfser As String = "SH-B1,SH-B2"
                        Dim mnfserval As String() = mnfser.Split(",")
                        For k = 0 To sernoval.Length - 1
                            oPDN.Lines.SerialNumbers.InternalSerialNumber = sernoval(k).Trim
                            oPDN.Lines.SerialNumbers.ManufacturerSerialNumber = mnfserval(k).Trim
                            oPDN.Lines.SerialNumbers.Quantity = linedetails(iRowNo).Quantity
                            oPDN.Lines.SerialNumbers.SetCurrentLine(k)
                            oPDN.Lines.SerialNumbers.Add()
                        Next
                    oPDN.CardCode = "C232323"
                    oPDN.Lines.ItemCode = "A00004"
                    'oGR.Lines.LineNum = 0
                    oPDN.Lines.BaseLine = 1
                    oPDN.Lines.BaseEntry = 202
                    'oGR.Lines.BaseRef = 203
                    oPDN.Lines.BaseType = 20
                    oPDN.Lines.Quantity = 1
                    oPDN.Lines.UnitPrice = 2
                    oPDN.Lines.WarehouseCode = '01'
                 oPDN.Lines.Add()
                 lRetCode = oPDN.Add

    Hi Vasanth,
    Invert the SetCurrentLine () and Add() at the end of the SSSerialNUmbers loop.
    Regards,
    Eric

  • 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

Maybe you are looking for

  • HP dv6662se microphone garbled after upgrading to Windows 7

    I recently upgraded my dv6662se laptop to Windows 7 (32 bit) from Vista. It has the built in webcam and microphone.  I also downloaded all of the subsequent Windows updates for it. The webcam still works but now the microphone only produces garbled n

  • Mini or others?

    I have been using MacTowerG4 (PowerPC) and started having problems (some we pages cannot be opned becuase I do not have an updated version of plug-in).  I am thinking to purchse a replacement.  Candidates are mini or iMac.  Becuase I have a Cinema Di

  • Refreshing Materialized View and (Bitmap) indexes

    In my data warehouse I have an MV that is re-built every night. 1. Initially it was fully refreshed, but dropping and re-creating was shown to be quicker as a general rule 2. It was sometimes sensitive to changes in the underlying objects 3. Its has

  • Will not sign in

    Setting up the software Photoshop elements 12 lets me sign in with premiere but keeps asking me sign in with elements program does not start and it does not say my password is incorrect changed that as well but no go ?

  • Printing the grid used in creating a PSE 10 drawing

    Hello, I have created a scaled floor plan dwng using the grid in PSE 10. It would be very useful to me to be able to print the grid directly with my drawing - preferably as a semi-opaque 'background'. Can this be done? Thanks, Dan