Apple - Can Finder delete a file directly and bypass moving it to the Trash?

Delete Immediately @ Github (free)

  1. Download the file Delete Immediately.service
  2. Move the file to ~/Library/Services. You may have to create the folder.
  3. Restart the finder by running killall Finder;
  4. You can also assign a keyboard shortcut to this service in System Preferences → Keyboard → Keyboard Shortcuts →Services

screenshot of the app's context menu

screenshot of the app's confirmation dialog


No - there's no shortcut for that, but there is a services menu to extend Finder, flexibly bending it to accommodate your wishes.

You'll want to define a service that calls a script to rm or srm and bind the keyboard shortcut of your preference to the service.

Automator's built in help can assist with learning to make a service.

Also invaluable is the site http://www.macosxautomation.com/ which is made by the automation guru Sal Soghoian


I came across an AppleScript that does something similar to what @bmike has suggested. User Jolly Jimmy listed in a forum post:

tell application "Finder"
    set theSelection to selection

    if theSelection is {} then
        beep
        activate current application
        display alert "No files are selected for deletion." message "Select one or more files to delete." as warning
    else
        activate current application
        display alert "Delete item(s)?" message "The selected item(s) will be deleted immediately. Are you sure you want to continue?" buttons {"OK", "Cancel"} as warning
        set buttonpressed to button returned of result

        if the buttonpressed is "OK" then
            repeat with i from 1 to (count theSelection)

                set item1 to (the quoted form of POSIX path of (item i of the theSelection as alias))
                set deleteit to "rm -rf " & item1 & ""

                try
                    do shell script deleteit
                on error
                    do shell script deleteit with administrator privileges
                end try
            end repeat
        end if
    end if
end tell

Add this script to the services menu, and you should be able to delete by right-clicking.

Tags:

Macos

Finder