How to delete files/folders recursively within a directory

Im trying to delete all files/folders recursively within the folder "HYPE TEMP EXPORTS" There isn't a way to do this now, if I select delete file its asking me specifically which one?

Will this work for you?

image

Trash will move it to the trash. This can be changed to suit your true need. Delete will not be placed in the trash and it will be gone immediately without confirmation.

The help page is here.

Hopefully, this is what you want.

KC

1 Like

That works, but I modified it a bit to do this and removes all files

Now say I want to run this Keyboard Maestro command in Automator "folder action" via keyboard key as the last entry keyboard in shortcut?

For your first part, if you want the files deleted, just change Trash to Delete, by clicking the arrow. The additional steps aren't necessary.

de5571198b62c34b9ff1085a492a878506c45d37

1 Like

that's cool, I want to Use Automator to press F6 to delete files? Is there a way I can do this?

For the second part, I don't have that ImageOptim to test but you can run folder triggers and shell scripts within Keyboard Maestro. Someone else may need to assist you with that one.

KC

So you already have Keyboard Maestro being triggered by the F6 key to delete the files with the method shown above. Now you want Automator to do the same thing?

You can check out this out video and maybe this will help you.

No, What I want to do is extend it by way of adding the last action which is the Maestro Keyboard command "F6"

The other actions in Automator are a different task altogether as they are a folder action, I just want to sequence the last part as "F6" key press.

You can check out this out video and maybe this will help you.

I saw that video prior to you showing me Its not same thing, its based on me opening an application but the application has a script that I created which is different than what Im looking for.

I need shell script that works by way of me specifying what keys to press.

This is more of what I need.

Or this.

Ive figured it out! Theres an option in keyboard maestro output a shell script code by choosing

and then adding into automator!

I was going to get to the shell script and the folder trigger earlier. I'm trying to figure out why you need Automator in the first place. :slight_smile:

Just so you know, you don't have to have a hot key trigger (F6) to do this, you can use a Folder Trigger for your HYPE TEMP. It seems everything you are trying to do can be done in Keyboard Maestro. You can also Execute a Shell Script from within your actions. But this is the phase where you organically learn the powers of KM and when you can use them. I think I only use Automator for quick Services. Other than that, I haven't touched it in almost 2 years.

I'm glad you are progressing.

KC

Very True! I might have, but I originally started with Automator and only found out about KM earlier on in the day and so with everything that’s going on with KM what I needed were the things I couldn’t really do in Automator. It’s great that KM has folder triggers. One day I’ll even consider KM to do it all for me.