Folders being deleted, not the items inside

I'm a bit confused...
Why is it trashing the folders themselves and not the items inside?
I usually set the variable with the paths separately in its own action, but I would assume that I don't need that if I use the "Text" option inside the For Each action?

What am I missing?

Unless I'm missing something, all you've provided to the macro is a list of folders—it knows nothing about their contents, it's just got a list of text.

Each time through the loop (four times total), it will simply look at that text, split the base name out of the path, then run your regex on it. This will never be true, because you're feeding it:

Backups
Safety Net Backups
Backups
Safety Net Backups

Then you tell it to delete the path if the condition is false—which is always is, so it deletes all the folders.

You need to put a For Each within your For Each loop, to actually grab the contents of the listed folders, then do your processing on those contents. Here's a demo macro that just displays results for items in the Desktop folder:

Finder list.kmmacros (7.3 KB)

And are you trying to only keep the hidden files, or only delete the hidden files? Because right now, this will delete all items except the hidden files—hopefully that was the intent?

-rob.

1 Like

I guess I had one of those moments where my brain stopped functioning...

You're right. I needed that extra For Each.
And yes, I want to keep the DS Store and the Icon files.

Everything is working now. Thanks!

1 Like

Those are usually invisible, so should be excluded if you don't check "Include invisibles" in the "For Each" action. So the "Filter" and "If..." are unnecessary, you can go straight to the "Trash" action.

Unless, of course, you've made them visible!