How to Add a Delete Option to the Context Menu in Mac

If you are a Mac user, you will know that it doesn’t allows you to permanently delete files from the context menu. There is only an option “Move to Trash” that move your file to the trash and you have to manually empty the trash to delete the file. Wouldn’t it be great if you can add a “Delete” option in the context menu so you can quickly and easily delete the file/folder?

In terminal, we can easily delete (or remove) a file or folder with the command “rm“. Coupled with the “-rf” flag, we can get the system to forcefully delete a file or folder without prompt. In this tutorial, I will show you how you can make use of this command, together with Automator, to add a “Delete” option to the context menu.

1. Open Automator and select “Services”.

automator-select-services

2. At the top of the right pane, select “files or folders” in “Finder”.

automator-select-files-in-finder

3. On the left most pane, select “Utilities” and drag the “Ask for Confirmation” option to the workflow. Enter the message to show up in the confirmation dialog.

automator-confirmation-message

4. Next, drag “Run Shell Script” to the workflow. Change the “Pass input” field to “as arguments”.

automator-run-shell-script

Paste the following lines into the shell script body:

5. Lastly, save the service with the name “Delete”.

automator-delete-option

That’s it. Now when you right click on any file or folder, you should see a “Delete” option. Select it and it will delete the file/folder.

An additional thing that you can do with this newly created “Delete” service is to bind a keyboard shortcut to it. You can then press the shortcut key to quickly delete the file.

1. In Finder, go to “Finder -> Services -> Services Preferences” in the menu bar. Locate the “Delete” option, click on it and select “Add shortcut”.

services-add-delete-shortcut-key

2. Once you have set your shortcut key, you can press it after you have selected the file(s) and it will delete the selected file(s).

Enjoy!

4 comments

  1. I like this a lot, and it has generally worked for me.

    BUT …. what I’m seeing when I right click on a file, is that the “Services” including the new “Delete” option are in a sub-menu at the bottom, so I have to go one level more to click on delete.

    Is there a way to expand this menu automagically so it looks like the screen shot in your tutorial?? (Maybe I have too many services .. there are 5 in the sub-menu list)

    • Yes, it collapses when there are too many services. It happened to me too. One of the solution is to reduce the number of services.

  2. Thanks for this it runs, but generates an error when I run it, “The action “Run Shell Script” encountered an error.” any ideas.
    I copied and pasted the script in place of the one generated by automator.
    Thanks
    Robert

Comments are closed.

Sponsored Stories