Search code examples
javascriptphotoshopsubdirectory

Access a subfolder of the active document path in photoshop


Please help, this is driving me mad.

This portion of my script replaces the content of a smart object. It successfully finds the file to use to replace in the activeDocument.path, but I cannot for the life of me get it to access the subfolder where I want all the images to be stored. To avoid having lots of files in the same folder as the PSD.

var idplacedLayerReplaceContents = stringIDToTypeID( "placedLayerReplaceContents" );
    var desc217 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var workingPath  = app.activeDocument.path;
    desc217.putPath( idnull, new File ("Texture_FOP.tif" ) );
executeAction( idplacedLayerReplaceContents, desc217, DialogModes.NO );

I've tried all sorts of things that I have read online, but being new to this either they just don't apply or I may be using them wrongly.

Thanks in advance.


Solution

  • You need to add your subfolder name to putPath:

    desc217.putPath( idnull, new File (workingPath + "/subfolder/Texture_FOP.tif" ) );