My Digital Story

Just to make live easier…

Permanently delete file in Mac OS X Finder

One of the most annoying part when using Apple Mac OS X is to permanently delete file in Finder ( the equivalent of Windows Explorer in Windows).

To delete file in Finder window, you need to press CMD+delete which will move the file to Trash bin. What actually happen from this action is, the file is just “hidden” from user in that particular folder/location. The file is yet permanently deleted. While the intention of this feature is well understood, which is to avoid us from mistakenly and unintentionally delete our files, sometimes it is just too annoying as after that we havw to go to Trash to actually empty the Trash. Furthermore, in Trash, you can not permanently delete individual file there. Once you press the “Empty” it will delete all the files in Trash.

For example, when you need to empty file in USB flash drive to physically free the disk spacw, if you just delete the files by moving them to Trash, your USB flash drive will still shows that it is still not yet EMPTY. Only after you empty the Trash, then only the USB flash drive will really be empty with full of free space.

Luckily someone has created an Applescript that will do just that, permanently delete your selected file in Finder. In addition to that you need an application called Spark that will assign keyboard key in order to execute the script. I assign Shift+delete keys to execute the script.

Both the Script and Spark application can be accessed below:
—————————————————————————

set frontAppPath to (path to frontmost application) as string

if the frontAppPath ends with “:Finder.app:” then
tell application “Finder”
set selectionList to get selection as list
set selectedCount to count items in selectionList
–Added code1
display dialog “Do you really want to delete this item?” buttons {“OK”, “Cancel”} default button 2
if the button returned of the result is “Cancel” then
return
else
–End of added code1
if selectedCount > 0 then
repeat with i from 1 to number of items in the selectionList
set selectedItem to item i of the selectionList
set selectedName to the name of selectedItem
set homePath to (path to home folder) as string
set trashPath to homePath & “.Trash:”
set deletePath to trashPath & selectedName & “:”

if not ((kind of selectedItem as string) is equal to “Volume”) then
if (selectedItem as string) contains “.Trash” then
set posixPath to POSIX path of (selectedItem as string) as string
do shell script “rm -rf “” & posixPath & “””
else
try
deletePath as alias
display dialog “Error: file named “” & selectedName & “” already exists in the Trash.”
on error
try
tell application “Finder” to delete selectedItem
do shell script “rm -rf ~/.Trash/”” & selectedName & “””
end try
end try
end if
end if
end repeat
end if
–Added code2
end if
–End of added code2
end tell
end if

—————————————————————————
Download SPARK

23/02/2011 - Posted by | Uncategorized | ,

1 Comment »

  1. thanks for the article/tip which is all well and good (I guess) but…
    LOL aren’t macs supposed to be easy to use? So in Windows you press shift delete to permanently delete; in OS X you have to install an application and that horrible script in order to achieve the same thing.
    Beggars belief.
    Btw, I run both OSX and Windoze.

    Comment by James | 19/09/2011


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: