Using BTT and Adobe Illustrator

Does anyone know/have a good way to select a specific layer in Illustrator? I'm trying to delete a layer called ART which is always called that, but there are sometimes four layers, sometimes five or six. I've tried using the mouse positioning, and that works as long as I have exactly the correct number of layers. There's no way I can see to select a layer by name.

I would script this. But since Illustrator understands JavaScript (jsx) and BetterTouchTool can't directly execute jsx (at least to my knowledge), I would embed it. Here is a code example that worked flawlessly for me with Illustrator 2024 with multiple layers and a layer "ART". Start an AppleScript action in BTT, copy the code snippet into it and it should work with the chosen trigger.

tell application "Adobe Illustrator"
do javascript "
// Function to delete layers by name
function deleteLayerByName(layerName) {
var doc = app.activeDocument;
for (var i = doc.layers.length - 1; i >= 0; i--) {
var layer = doc.layers[i];
if ( === layerName) {

// Call the function to delete the 'ART' layer

end tell

Wow, thank you! I haven't gotten too far into scripting on Illustrator so I didn't know this was possible. And if I make this, between BTT, Text Expander and more, I'm sure I can automate it somehow.

Thank you!!

No problem, happy to help. I'm not sure where TextExpander comes into play here, but I hope you have success with it.