Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Layer Comps / Layers to Files: Refer to document title when used as an action

Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Hi all,

 

I'm trying to use the Layer Comps to Files or Layers to Files tools as part of an action. I want the final output to be formatted as:

 

[DocumentTitle]_[LayerComp/LayerTitle].jpg

 

At present, the second part of the formatting works fine, but the action records the first part as it is manually entered. Is there any way to amend the .jsx script/s to fix this?

 

Hope this makes sense! Any help would be greatly appreciated 🙂

TOPICS
Actions and scripting, macOS

Views

493

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 09, 2021 Jun 09, 2021
is this what you are looking for?//some useful settings, edit where appropriate var destenationFolder = "E:\\LAPS\\TestFiles"; //where to safe the file var fileName = null; //empty as we're generating these, if you want to specify a single name, do it here var slctdonly = false; //set to true of you only want the selected layercomps exported //list active documents var documentList = app.documents; for( var i = 0; i<document...

Likes

Translate

Translate
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

I'm not sure you want to do that with actions, preferably you'd do that with a complete script. 
Are you creating a new doc with that name and save as jpg or do you use the "safe for web"  function?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Hi Patrick,

 

Thanks for the reply. 

 

Basically, we have PSDs which come in with different filenames ("FILE_A" today, "FILE_B" tomorrow). A common requirement is to add 6 colour overlays and export as 6 images.

 

At the moment I run a script to add the overlays and create layer comps ("-Black", "-Blue", etc...) then use Layer Comps to Files and manually insert the filename. Fine for small batches but on large batches it can be tedious and imprecise. 

 

It doesn't really matter whether they're saved as JPG or Save for Web. If there's a workaround using SfW we could easily go with that...?

 

Thanks again.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

getting back to you on this. just so you know - looking into this triggered more then I was expecting 😉

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

is this what you are looking for?

//some useful settings, edit where appropriate
var destenationFolder = "E:\\LAPS\\TestFiles";      //where to safe the file
var fileName = null;                                  //empty as we're generating these, if you want to specify a single name, do it here
var slctdonly = false;                              //set to true of you only want the selected layercomps exported
 


//list active documents
var documentList = app.documents;

for( var i = 0; i<documentList.length; i++ ){
        app.activeDocument = documentList[i];
        theName = (fileName == null)? app.activeDocument.name.replace('.psd',''):fileName;
        execLC2F( theName, destenationFolder, slctdonly );
}

function execLC2F( theFileName, theDestenationFolder, onlySelected ){
    var LC2F = stringIDToTypeID( "cf34b502-2013-4d07-8431-1dfd634ee0cd" );
        var desc324 = new ActionDescriptor();
        var idMsge = charIDToTypeID( "Msge" );
        desc324.putString( idMsge, """Layer Comps To Files action settings""" );
        var iddestination = stringIDToTypeID( "destination" );
        desc324.putString( iddestination, theDestenationFolder );
        var idfileNamePrefix = stringIDToTypeID( "fileNamePrefix" );
        desc324.putString( idfileNamePrefix, theFileName );
        var idselectionOnly = stringIDToTypeID( "selectionOnly" );
        desc324.putBoolean( idselectionOnly, onlySelected );  //<----

    executeAction( LC2F, desc324, DialogModes.NO );
}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

oh, copy and safe as [path/to/somewhere]/[something].jsx, then open it from the file>scripts>browse menu (you could make an action for that)

it'll open the layercomp to file dialog for each open document you got, with the filename preloaded

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Incredible, thank you so much for your time on this, exactly what I was looking for!!

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

LATEST

NP, it was an interesting diversion, glad it is useful to you: nothing worse then wasting time with tedious repetitive nonsense 😉

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

But maybe this helps:

var theNewFilename = app.activeDocument.name + "_" + app.activeDocument.activeLayer.name;
theNewFilename = theNewFilename.replace('.psd',''); 
alert( theNewFilename );

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines