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”.
2. At the top of the right pane, select “files or folders” 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.
4. Next, drag “Run Shell Script” to the workflow. Change the “Pass input” field to “as arguments”.
Paste the following lines into the shell script body:
5. Lastly, save the service with the name “Delete”.
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.
Binding a shortcut key to Delete file
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”.
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).