Skip to main content
Participating Frequently
August 14, 2009
Answered

Scripting with LayerComps, delete hidden layers and save each Layer comps to an new file

  • August 14, 2009
  • 2 replies
  • 5346 views

Good morning,

I haven't tried the search, I just found this forum and was thinking I need to ask people how to script with adobe.

I would love to have a script that does the following scenario:

1. For each layer Comp I got on an document I want to save each of them to a new PSD file

2. For each file I want to delete all the hidden layers on each "new psd" file

3. Have some proper and easy names on each file

And preferble a script I can reuse on more photoshop projects

Edited: We are using PhotoShop CS3 currently at work if thats a problem?

Seems "layer groups" need to go away also (so we can open it in Elements).

kind regards

Andreas

This topic has been closed for replies.
Correct answer c.pfaffenbichler

I would be very happy with any help I can get, really appreciated


I’ve tried to cobble together a Script.

It includes a provision to recreate Clipping Masks for the layers moved out of their original parental LayerSets, but I’m not so sure about that …

I may have overlooked any number of additional potential sources of problems, but You could give it a try.

The Script would replace existing files of the resulting names in the same location without prompting by the way!

2 replies

voigtanAuthor
Participating Frequently
August 19, 2009

Tried to find somehow to debug the code,

added:

        try
        {
            var id26 = charIDToTypeID( "Dlt " );
            var desc6 = new ActionDescriptor();
            var id27 = charIDToTypeID( "null" );
            var ref6 = new ActionReference();
            var id28 = charIDToTypeID( "Lyr " );
            var id29 = charIDToTypeID( "Ordn" );
            var id30 = stringIDToTypeID( "hidden" );
            ref6.putEnumerated( id28, id29, id30 );
            desc6.putReference( id27, ref6 );
            executeAction( id26, desc6, DialogModes.NO );
        }
        catch(e)
        {
        };

But I have no idea what it actually means, but on the file Im currently working with seems takes forever to get it to finish the first layer comp. when I didnt have the try/catch error it said the executeAction was a problem (see error above), but I have a hard time to see why it shouldnt work, it worked on the other file I worked with.

Can it be that we use swedish characters on some layers/Layer Comps? Or could it be that we have a "warning" on font/text-layers?

Inspiring
August 19, 2009

It basically says 'do command delete all hidden layers'. If that part of the code is not in the try/catch there is an error if there are no hidden layers. Adding the try will not change the speed of the script.

A script that works with a document that has lots of layers can be slow. Does the doc you are having trouble with have a lot more layer than the one that worked fine?

If not contact me by PM and I will try to help understand the speed difference.

Mike

c.pfaffenbichler
Community Expert
Community Expert
August 14, 2009

All that should be doable with JavaScript and would be applicable to any files that contain LayerComps.

CS3 should be no problem in that regard to the best of my knowledge.

Removing the LayerSets would appear to be a bad idea if they are masked or set to some Blend Mode other than Pass Through (apart from the structure).

I haven’t used Elements, but mutilating photoshop-files in order to be able to open them in Elements seems harsh.

Can Elements handle Smart Objects, Adjustment Layers, Alpha Channels, Paths, Notes, …?

voigtanAuthor
Participating Frequently
August 14, 2009

I downloaded Elements to see what the problem is within the office, it seems Elements can open all of the layers, but the problem is that we cant open "Groups" or what I want to call them "folders". The folders exists but they are more like an layer within itself.

So The "goal" would be:

1, Select a Layer Comp (each of them in the end)

2 .Delete all the hidden layers

3. Move the layers out from the group/folder

4. Export the PSD file

5. "Bring back the deleted layers"

6. Go back to step 1 and redo all until we are done.

Could anyone give some nice code, I know Javascript but no idea how to work with it in Photoshop

c.pfaffenbichler
Community Expert
Community Expert
August 14, 2009

What about Layer Masks on Layer Sets (folders)? And Layer Sets’ Blend Modes?

Simply adding the masks to all the layers when moving them to the top level (if they don’t have masks already) could alter the appearance (i.e. mess things up).

Moving all the layers out of their groups makes the whole thing significantly more difficult in any case as far as I can see.