I want to delete selected files in finder to be deleted bypassing trash can? Is there any such util or script?
-Simmi
do shell script "rm -rf /path/to/filename" -- requires the posix path though there are ways around that
I am newbie to mac. Is there easy way to put a toolbutton on finder or put command under Action menubar button so that it will delete selected files in Finder window bypassing trash. I don’t know enough how to get script above working. I tried utility “Graveyard” from macupdate but it did not work on my mac.
How about a droplet? If you open the script below inside of Script Editor, choose Save As from the File menu, then choose Application as the File Format. If you also make sure none of the little boxes are checked (Run Only, Startup Screen, Stay Open), then whenever you double click the icon, you get the nifty instruction box:
on open the_items_list
repeat with the_item in the_items_list
do shell script ("rm -rf " & quoted form of (POSIX path of the_item))
end repeat
end open
on run
display dialog "Drop files and folders onto this icon for instant erasure."
end run
You should know that anything you drag onto this droplet will be gone FOREVER, so be careful.
Hi,
alternatively you can save the following script as application
and drag it to the toolbar of some Finder window (next to the search field).
Then select one or multiple files and click on the icon.
I’d like to repeat Craig’s warning being very careful with it, therefore I added a dialog
tell application "Finder" to set sel to selection
repeat with i in sel
display dialog "Do you really want to delete" & return & "the selected item(s) permanently" with icon 2
do shell script "rm -rf " & quoted form of POSIX path of (i as alias)
end repeat
When using the selection, it’s very easy to accidently delete a wrong item even with a warning dialog. You would probably want a listing of the items that are to be deleted or something. Personally, I wouldn’t use selected items. The drag and drop sounds better. At least you can se what items you’re deleting most of the time.
Hi kel,
you’re absolutely right. I just wanted to show the option to do this.
Here’s a little change of the script above. You have confirm for each item seeing the name of file/folder
property file_folder : {"file ", "folder "}
tell application "Finder" to set sel to selection
repeat with i in sel
set {fName, isFolder} to {name, folder} of (info for i as alias)
display dialog "Do you really want to delete" & return & item ((isFolder as integer) + 1) of file_folder & quote & fName & quote & " permanently" with icon 2
do shell script "rm -rf " & quoted form of POSIX path of (i as alias)
end repeat
One of the habits you get into is pressing the button and before you know it, the file’s gone. Happened to me several times before OSX, with the are you sure dialog.
Dear god am I familiar with that.
Edit: Cause I can’t spell
I once deleted two days of work on a paper. Realized it one second after I pressed the button. Nothing goes near the trash now without close inspection, except test files.
Heheh… I now do heavy duty scripting on a dev box actually… While developing a script one time I messed up a path in a shell script and my “rm” command traversed into my home directory
That makes me think about the importance of backing up data every 5 Minutes . . .
Recently I finished a project (on a server in my home network), was so happy to get an early nights rest, I didn’t bother to backup.
In the morning however, the server wouldn’t start anymore. => Real bad HD-failure. Haven’t been able to recover a single bit. (of the critical code, I had some older backups)
I can only encourage everyone to double, triple and quadruple backup in as short intervals as you can.
Fast, cheap and efficient backup scripts/solutions, anyone?
how did we segway from deleting to backing up?
What is wrong with simply selecting the files to delete and pressing command-delete?