Page 1 of 1

Document path saving,searching problem..

Posted: Tue Jun 11, 2019 9:51 am
by addamski
Hi,
Please could someone help me, i'm new to learning scripting, and need to know how to do the following.
I've been trying my hardest with listener etc, but this is as far as I have go with these two parts of the script.
(For reference the script will look for named smart objects and replace the contents and show/hide them while it saves out .tif files of each to the active document folder).

1. Save files to the active document path..

Code: Select all

var idsave = charIDToTypeID( "save" );
    var desc255 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc256 = new ActionDescriptor();
        var idBytO = charIDToTypeID( "BytO" );
        var idPltf = charIDToTypeID( "Pltf" );
        var idIBMP = charIDToTypeID( "IBMP" );
        desc256.putEnumerated( idBytO, idPltf, idIBMP );
        var idLZWC = charIDToTypeID( "LZWC" );
        desc256.putBoolean( idLZWC, true );
        var idsaveTransparency = stringIDToTypeID( "saveTransparency" );
        desc256.putBoolean( idsaveTransparency, true );
    var idTIFF = charIDToTypeID( "TIFF" );
    desc255.putObject( idAs, idTIFF, desc256 );
    var idIn = charIDToTypeID( "In  " );
    desc255.putPath( idIn, new File( "O:\\Location\\FOP.tif" ) );
    var idDocI = charIDToTypeID( "DocI" );
    desc255.putInteger( idDocI, 456 );
    var idCpy = charIDToTypeID( "Cpy " );
    desc255.putBoolean( idCpy, true );
    var idLyrs = charIDToTypeID( "Lyrs" );
    desc255.putBoolean( idLyrs, false );
    var idsaveStage = stringIDToTypeID( "saveStage" );
    var idsaveStageType = stringIDToTypeID( "saveStageType" );
    var idsaveBegin = stringIDToTypeID( "saveBegin" );
    desc255.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );
executeAction( idsave, desc255, DialogModes.NO );
I have tried various ways of adding activeDocument.path in the save portion of the code with no luck.


2. Look for files in the active document path but within a named subfolder to replace smart object contents.

I tried this below (a), but it opens a location for me to choose a file in the wrong place. I based this off (b) which works with an named path.

(a)- amended by me and doesn't work.

Code: Select all

var idplacedLayerReplaceContents = stringIDToTypeID( "placedLayerReplaceContents" );
    var desc217 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    desc217.putPath( idnull, new File( activeDocument.path + '/Output/' + "FOP") );
executeAction( idplacedLayerReplaceContents, desc217, DialogModes.NO );
(b) - works with path.
var idplacedLayerReplaceContents = stringIDToTypeID( "placedLayerReplaceContents" );
var desc217 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc217.putPath( idnull, new File( "O:\\Location\\Output\\FOP.tif" ) );
executeAction( idplacedLayerReplaceContents, desc217, DialogModes.NO );

Sorry if this is a very basic problem, but as i'm learning through listener, I can't get past this part.
Any help would be greatly appreciated.

Thanks