Home » Questions » Computers [ Ask a new question ]

Permanently deleting files on Mac OS

Permanently deleting files on Mac OS

A while back, as relatively new Mac OS X user, I was surprised to learn that you cannot easily delete files. Directly, that is, without moving them to the trash first. On Windows and Linux this can obviously be done with ease, but not so on the Mac.

Asked by: Guest | Views: 70
Total answers/comments: 5
Guest [Entry]

I'm not so happy with the way Mac OS X handles this either. If I really want to delete something, especially from USB memory sticks, I usually fire up Terminal and rm the files manually.
Guest [Entry]

"The Terminal-less way of solving this conundrum is to cast the following spell to appease the Apple gods, like so :

Select the file to be sacrificed followed by reciting:
⌘ Delete
⌘ ⇧ ⌥ ⌫

This will send the file to Trash, and then delete the whole Trash, thus should send the victim (and all other trashed items) to oblivion."
Guest [Entry]

"Part of the beauty of Mac OS X is that while it's dead easy for inexperienced users to find their way around and get stuff done, power users can ""fiddle with the system"" by using the power of the underlying Unix via a command shell (i.e. Terminal.app).

@Leauki is right about using the unix command rm, but BE VERY CAREFUL, particularly if using the -rf flags! There's no safety-net and you can do serious damage, up to and including deleting your own root filesystem!

My recommendation is not to use absolute paths with rm, but to cd into the diretory you want to work with first, and then for example:

rm -rf ./<subpath to file to delete> where the ./ in the path forces rm to operate only in the directory you're currently in."
Guest [Entry]

"I came up with the following applescript, which I bound to shift del with Keyboard Maestro, so it now works as in windows. With the item selected in Finder, shift del will run the script, which displays a dialog warning of the permanent deletion of the item with its name. Clicking OK completes the delete.

I don't know much about shell commands, and some of the previous posters warned of the danger of using rm -rf, which is something I have done in the script. It seems to work as predicted for me so far though.

tell application ""Finder""
set myPosixPath to selection as text --returns an alias path
set myPosixPath to POSIX path of myPosixPath --set it to posix style path with backslashes

--identify whether it's a file or folder. Only for the warning dialog.
if character -1 of myPosixPath is ""/"" then
set itemType to ""folder""
else
set itemType to ""file""
end if

--display a warning
display dialog myPosixPath & ""

This cannot be undone."" with title ""Really permanently delete this "" & itemType & ""?""
do shell script ""rm -rf "" & quoted form of myPosixPath --execute a shell script to delete the item
end tell"
Guest [Entry]

"I think that this is done for user consistency, and safety. I think that is better to keep files for longer than required and use space instead of being gung-ho and deleting them straight away.

This is a bit annoying though when you are working with USB sticks and you move them to a windows machine and go ... where is all my space ... and what is this annoying .trash folder."