2 Replies Latest reply on Sep 25, 2015 4:30 AM by pprettylin@gmail.com
      • 1. Re: How to Change the default folder name when using Save for Web by java script?
        Chuck Uebele Adobe Community Professional & MVP

        You can try using scriptlistener to record the code. The change the last line from NO to ALL for the dialogs, so that the dialog box comes up - if you want it to. There were two places in the code for saving files: one where is actually saved the file, and the other where the default was folder is. I didn't see that it changed anything with that. So you could just use the first listing for a path in the code below.

         

        #target photoshop
        
        var idExpr = charIDToTypeID( "Expr" );
            var desc19 = new ActionDescriptor();
            var idUsng = charIDToTypeID( "Usng" );
                var desc20 = new ActionDescriptor();
                var idOp = charIDToTypeID( "Op  " );
                var idSWOp = charIDToTypeID( "SWOp" );
                var idOpSa = charIDToTypeID( "OpSa" );
                desc20.putEnumerated( idOp, idSWOp, idOpSa );
                var idDIDr = charIDToTypeID( "DIDr" );
                desc20.putBoolean( idDIDr, true );
                var idIn = charIDToTypeID( "In  " );
                desc20.putPath( idIn, new File( "C:\\Users\\csuebele\\Pictures\\LR shortcuts" ) );//Here's where it actually saves
                var idFmt = charIDToTypeID( "Fmt " );
                var idIRFm = charIDToTypeID( "IRFm" );
                var idPNtwofour = charIDToTypeID( "PN24" );
                desc20.putEnumerated( idFmt, idIRFm, idPNtwofour );
                var idIntr = charIDToTypeID( "Intr" );
                desc20.putBoolean( idIntr, false );
                var idTrns = charIDToTypeID( "Trns" );
                desc20.putBoolean( idTrns, true );
                var idMtt = charIDToTypeID( "Mtt " );
                desc20.putBoolean( idMtt, true );
                var idEICC = charIDToTypeID( "EICC" );
                desc20.putBoolean( idEICC, false );
                var idMttR = charIDToTypeID( "MttR" );
                desc20.putInteger( idMttR, 255 );
                var idMttG = charIDToTypeID( "MttG" );
                desc20.putInteger( idMttG, 255 );
                var idMttB = charIDToTypeID( "MttB" );
                desc20.putInteger( idMttB, 255 );
                var idSHTM = charIDToTypeID( "SHTM" );
                desc20.putBoolean( idSHTM, false );
                var idSImg = charIDToTypeID( "SImg" );
                desc20.putBoolean( idSImg, true );
                var idSWsl = charIDToTypeID( "SWsl" );
                var idSTsl = charIDToTypeID( "STsl" );
                var idSLAl = charIDToTypeID( "SLAl" );
                desc20.putEnumerated( idSWsl, idSTsl, idSLAl );
                var idSWch = charIDToTypeID( "SWch" );
                var idSTch = charIDToTypeID( "STch" );
                var idCHsR = charIDToTypeID( "CHsR" );
                desc20.putEnumerated( idSWch, idSTch, idCHsR );
                var idSWmd = charIDToTypeID( "SWmd" );
                var idSTmd = charIDToTypeID( "STmd" );
                var idMDCC = charIDToTypeID( "MDCC" );
                desc20.putEnumerated( idSWmd, idSTmd, idMDCC );
                var idohXH = charIDToTypeID( "ohXH" );
                desc20.putBoolean( idohXH, false );
                var idohIC = charIDToTypeID( "ohIC" );
                desc20.putBoolean( idohIC, true );
                var idohAA = charIDToTypeID( "ohAA" );
                desc20.putBoolean( idohAA, true );
                var idohQA = charIDToTypeID( "ohQA" );
                desc20.putBoolean( idohQA, true );
                var idohCA = charIDToTypeID( "ohCA" );
                desc20.putBoolean( idohCA, false );
                var idohIZ = charIDToTypeID( "ohIZ" );
                desc20.putBoolean( idohIZ, true );
                var idohTC = charIDToTypeID( "ohTC" );
                var idSToc = charIDToTypeID( "SToc" );
                var idOCzerothree = charIDToTypeID( "OC03" );
                desc20.putEnumerated( idohTC, idSToc, idOCzerothree );
                var idohAC = charIDToTypeID( "ohAC" );
                var idSToc = charIDToTypeID( "SToc" );
                var idOCzerothree = charIDToTypeID( "OC03" );
                desc20.putEnumerated( idohAC, idSToc, idOCzerothree );
                var idohIn = charIDToTypeID( "ohIn" );
                desc20.putInteger( idohIn, -1 );
                var idohLE = charIDToTypeID( "ohLE" );
                var idSTle = charIDToTypeID( "STle" );
                var idLEzerothree = charIDToTypeID( "LE03" );
                desc20.putEnumerated( idohLE, idSTle, idLEzerothree );
                var idohEn = charIDToTypeID( "ohEn" );
                var idSTen = charIDToTypeID( "STen" );
                var idENzerozero = charIDToTypeID( "EN00" );
                desc20.putEnumerated( idohEn, idSTen, idENzerozero );
                var idolCS = charIDToTypeID( "olCS" );
                desc20.putBoolean( idolCS, false );
                var idolEC = charIDToTypeID( "olEC" );
                var idSTst = charIDToTypeID( "STst" );
                var idSTzerozero = charIDToTypeID( "ST00" );
                desc20.putEnumerated( idolEC, idSTst, idSTzerozero );
                var idolWH = charIDToTypeID( "olWH" );
                var idSTwh = charIDToTypeID( "STwh" );
                var idWHzeroone = charIDToTypeID( "WH01" );
                desc20.putEnumerated( idolWH, idSTwh, idWHzeroone );
                var idolSV = charIDToTypeID( "olSV" );
                var idSTsp = charIDToTypeID( "STsp" );
                var idSPzerofour = charIDToTypeID( "SP04" );
                desc20.putEnumerated( idolSV, idSTsp, idSPzerofour );
                var idolSH = charIDToTypeID( "olSH" );
                var idSTsp = charIDToTypeID( "STsp" );
                var idSPzerofour = charIDToTypeID( "SP04" );
                desc20.putEnumerated( idolSH, idSTsp, idSPzerofour );
                var idolNC = charIDToTypeID( "olNC" );
                    var list4 = new ActionList();
                        var desc21 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCzerozero = charIDToTypeID( "NC00" );
                        desc21.putEnumerated( idncTp, idSTnc, idNCzerozero );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list4.putObject( idSCnc, desc21 );
                        var desc22 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNConenine = charIDToTypeID( "NC19" );
                        desc22.putEnumerated( idncTp, idSTnc, idNConenine );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list4.putObject( idSCnc, desc22 );
                        var desc23 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwoeight = charIDToTypeID( "NC28" );
                        desc23.putEnumerated( idncTp, idSTnc, idNCtwoeight );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list4.putObject( idSCnc, desc23 );
                        var desc24 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwofour = charIDToTypeID( "NC24" );
                        desc24.putEnumerated( idncTp, idSTnc, idNCtwofour );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list4.putObject( idSCnc, desc24 );
                        var desc25 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwofour = charIDToTypeID( "NC24" );
                        desc25.putEnumerated( idncTp, idSTnc, idNCtwofour );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list4.putObject( idSCnc, desc25 );
                        var desc26 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwofour = charIDToTypeID( "NC24" );
                        desc26.putEnumerated( idncTp, idSTnc, idNCtwofour );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list4.putObject( idSCnc, desc26 );
                desc20.putList( idolNC, list4 );
                var idobIA = charIDToTypeID( "obIA" );
                desc20.putBoolean( idobIA, false );
                var idobIP = charIDToTypeID( "obIP" );
                desc20.putString( idobIP, """""" );
                var idobCS = charIDToTypeID( "obCS" );
                var idSTcs = charIDToTypeID( "STcs" );
                var idCSzeroone = charIDToTypeID( "CS01" );
                desc20.putEnumerated( idobCS, idSTcs, idCSzeroone );
                var idovNC = charIDToTypeID( "ovNC" );
                    var list5 = new ActionList();
                        var desc27 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCzeroone = charIDToTypeID( "NC01" );
                        desc27.putEnumerated( idncTp, idSTnc, idNCzeroone );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc27 );
                        var desc28 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwozero = charIDToTypeID( "NC20" );
                        desc28.putEnumerated( idncTp, idSTnc, idNCtwozero );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc28 );
                        var desc29 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCzerotwo = charIDToTypeID( "NC02" );
                        desc29.putEnumerated( idncTp, idSTnc, idNCzerotwo );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc29 );
                        var desc30 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNConenine = charIDToTypeID( "NC19" );
                        desc30.putEnumerated( idncTp, idSTnc, idNConenine );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc30 );
                        var desc31 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCzerosix = charIDToTypeID( "NC06" );
                        desc31.putEnumerated( idncTp, idSTnc, idNCzerosix );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc31 );
                        var desc32 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwofour = charIDToTypeID( "NC24" );
                        desc32.putEnumerated( idncTp, idSTnc, idNCtwofour );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc32 );
                        var desc33 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwofour = charIDToTypeID( "NC24" );
                        desc33.putEnumerated( idncTp, idSTnc, idNCtwofour );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc33 );
                        var desc34 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwofour = charIDToTypeID( "NC24" );
                        desc34.putEnumerated( idncTp, idSTnc, idNCtwofour );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc34 );
                        var desc35 = new ActionDescriptor();
                        var idncTp = charIDToTypeID( "ncTp" );
                        var idSTnc = charIDToTypeID( "STnc" );
                        var idNCtwotwo = charIDToTypeID( "NC22" );
                        desc35.putEnumerated( idncTp, idSTnc, idNCtwotwo );
                    var idSCnc = charIDToTypeID( "SCnc" );
                    list5.putObject( idSCnc, desc35 );
                desc20.putList( idovNC, list5 );
                var idovCM = charIDToTypeID( "ovCM" );
                desc20.putBoolean( idovCM, false );
                var idovCW = charIDToTypeID( "ovCW" );
                desc20.putBoolean( idovCW, true );
                var idovCU = charIDToTypeID( "ovCU" );
                desc20.putBoolean( idovCU, true );
                var idovSF = charIDToTypeID( "ovSF" );
                desc20.putBoolean( idovSF, true );
                var idovCB = charIDToTypeID( "ovCB" );
                desc20.putBoolean( idovCB, true );
                var idovSN = charIDToTypeID( "ovSN" );
                desc20.putString( idovSN, """c:\photos""" );//Here's where the default folder is suppose to go.
            var idSaveForWeb = stringIDToTypeID( "SaveForWeb" );
            desc19.putObject( idUsng, idSaveForWeb, desc20 );
        executeAction( idExpr, desc19, DialogModes.ALL );