• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to delete the last (recent) Layer Comps? (specify amount to a func)

Advocate ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

I sometimes like to have an action lay down some variations + Layer Comps.

 

I flip through the Comps and when I've made my choice, I want to delete those temporary, say, last 2 to 5 Comps.

 

Is this possible with a script where I specify the amount of Comps to delete from the bottom?

 

After I decided on my favorite, I don't need any of the Comps anymore, and I can handle the rest with the action.  Would just like a few scripts that "Delete 2 Last Comps", 3, 4, 5.

 

As they always seem to be added on the bottom, I'm hoping it's not elusive to do this...

Until now, I've always deleted the whole lot – but that's not professional... 😉

TOPICS
Actions and scripting

Views

6.5K

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

LEGEND , May 26, 2021 May 26, 2021

 

while((lCs = (aD = activeDocument).layerComps).length &&
(lC = lCs[lCs.length - 1]).name.split(/^TMP_/)[1]) lC.remove()

 

Votes

Translate

Translate
Adobe
Advocate ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

In this simple example, I can let the action do the cleanup of the Comps too. But it's messier and more work than calling a script to "Delete last 3 Comps."  It feels safer to me too (while it may not be...).

Votes

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
Advocate ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

"My action removes Red and Blue layer."

> Correction: a script does that. It keeps the selected layer and throws away the rest (all three are inside a Group, but I kept it simple here).

Votes

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
People's Champ ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

app.activeDocument.layerComps.removeAll();

 

Do you need this?

Votes

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
Advocate ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

I probably got that out of a PDF... 😉

That's what I've been using.

But it doesn't respect what was already there. That's what I now wanna improve on.

 

Votes

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
People's Champ ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

It is probably easier to create temporary LayerComps with a fixed or standard name, for example, TMP or TMP1, TMP2, etc., perhaps using a script (or action), and then delete these temporary LayerComps based on the name.

Votes

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
Advocate ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

I have this idea often but never tried it.

I would wanna keep meaningful names though, so I'm usually wondering if I can delete layers based on a prepended code.

 

For example, ...

tmp_ Meaningful description 1

tmp_ Meaningful description 2

tmp_ Meaningful description 3

 

Then delete all Comps starting with tmp_

Votes

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
Advocate ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

I then wouldn't need the DUMMY Comp and it would be a touch less hardcoded (just the 'tmp_')

Votes

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
Advocate ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

The right prepended characters could even help to make the new Comps stand out nicely, so I guess it is the better solution.  My mistake to not think of it from the start...

Votes

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
LEGEND ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

 

while((lCs = (aD = activeDocument).layerComps).length &&
(lC = lCs[lCs.length - 1]).name.split(/^TMP_/)[1]) lC.remove()

 

Votes

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
Advocate ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

A great combined effort...!

 

Signfeld: awesome ideas  😜

r-bin: wise solutions

Kukurykus: immaculate finisher  😉

 

Thank You Script Team!

Votes

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
Advocate ,
Jul 01, 2022 Jul 01, 2022

Copy link to clipboard

Copied

(1) Your code did exactly what I needed at the time: it deletes Layer Comps prepended with "– ", but only from the bottom up.

As it doesn't work to remove any prepended LC, I've been trying to rewrite it using a "for" loop structure, but I'm ashamed to always get errors...

(Help 😛 )

LC.jpg

I want removed: – LC 3, – LC 6, – LC 4

 

UPDATE.: Figured it out, I think...

 

 

var doc = app.activeDocument;

   for(i = doc.layerComps.length-1; i >= 0 ; i--){
        if( doc.layerComps[i].name.split(/^– /)[1] ){
            doc.layerComps[i].remove();
        }
    }

 

 

 

(2) Also, to execute "next Layer Comp," it works using Script Listener code or xtools "action to script," but is that the fastest way? (This doesn't have to fly of course; just wondering if there is shorter code that is not 50ms slower.)

Votes

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
New Here ,
Jan 22, 2023 Jan 22, 2023

Copy link to clipboard

Copied

LATEST

Install this program

1200px-Adobe_Premiere_Pro_CC_icon.svg.png

Votes

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