Skip to main content
Inspiring
April 25, 2024
Answered

Recording Delete Hidden Layers in an Action (Illustrator)

  • April 25, 2024
  • 2 replies
  • 2072 views

I have a series of Illustrator AI files, some with hidden layers that I need to delete.

 

I can use the Delete Hidden Layers command within the Layers panel to remove them all, manually.

 

However, this command is not recordable as an Action.

 

I can record "Unlock All Layers." (Many of my layers are also locked.) In the Actions panel, it shows as:

>Show:

   Unlock All Layers

 

When I try to record "Delete Hidden Layers," it's recorded in the Actions panel as:

>Show:

   Name:

 

This step of the action just creates a new Layer (and prompts me to name it).

 

I've also tried "Insert Menu Item" from the Actions panel, but it appears menu items from panels are not included in that option.

 

Is it really just impossible to perform this menu function without resorting to writing code?

 

Why are so many of Illustrator's commands and menu items not actionable?

Correct answer Kurt Gold

Here is the download link, Lunnson:

 

Delete Layers

 

Try it out and report if it's suitable.

2 replies

pixxxelschubser
Community Expert
Community Expert
April 25, 2024

The problem can be partially, though unfortunately not completely, circumvented.

(Empty layers remain in the document, but all hidden objects are deleted.)

 

You can try to go the opposite way:

 

That means:
at first: tick on: Paste remember layers

action name: Delete hidden

  • layer command: unlock all layers
  • select all
  • cut
  • layer command: all layers visible
  • unlock all
  • all visible
  • select all
  • delete
  • paste in place

 

Inspiring
April 25, 2024

that's a very interesting workaround. The simplest solutions are usually best.

 

Here's my only concern (and one that would need testing): if two items, same layer or different, were interacting with each other with effects or blending modes (clipping masks, etc.), would cutting them out of the document and then pasting them back in preserve all of that? Would those interactions between objects remain through a cut and paste?

Kurt Gold
Community Expert
Community Expert
April 25, 2024

Considering all possible special cases was one reason why I asked for some Illustrator sample files, so one can inspect what action approaches are realistic or what else has to be done to make them work.

Kurt Gold
Community Expert
Community Expert
April 25, 2024

You are right that the implementation of the Delete Hidden Layers command in the Actions palette is nonsense, just as the command itself (strictly speaking) because it also deletes objects and not just layers.

 

Currently, you'd indeed have to resort to creating a script for that task. I've created one that does delete empty, locked, hidden or non-printing main layers and sublayers. Currently it does not delete hidden objects. Let me know if that may help you and I'll post a download link.

 

As for your question: Why are so many of Illustrator's commands and menu items not actionable?

 

The answer is pretty simple and disappointing: It's because for many years Adobe has lost sight of implementing many commands as actionable commands.

 

About ten years ago, there was an official announcement indicating that the entire actions architecture was going to be revamped. Unfortunately, it was kicked into the long grass.

Known Participant
October 15, 2024

I would love to play around with that script if it's available. I was trying to do the same thing with creating an action that uses the delete hidden layers with no success. However, I need to keep locked layers intact. 

Thank you!

Kurt Gold
Community Expert
Kurt GoldCommunity ExpertCorrect answer
Community Expert
October 15, 2024

Here is the download link, Lunnson:

 

Delete Layers

 

Try it out and report if it's suitable.