Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (59 sloc) 1.7 KB
Author: Nguyen Kien Trung
This script is to delete files permanently without Trashing.
Interactive dialog is displayed for user to confirm the action.
Works on Leopard
property parent : application "Finder"
set OK_MSG to "Sure, I am"
set CANCEL_MSG to "Sorry, I ain't"
set ABORT_MSG to "Abort, safety first"
set IGNORE_MSG to "Pass, try next one"
tell application "Finder"
set selectionList to get selection as list
set selectionCount to count items in selectionList
set asking_dialog to display dialog "There are " & selectionCount & Â
" selected folders/files.
Are you sure to delete permanently?" with title Â
"Warning" with icon stop Â
buttons {CANCEL_MSG, OK_MSG} Â
default button CANCEL_MSG
set button_pressed to button returned of result
if button_pressed is OK_MSG then
if selectionCount > 0 then
repeat with i from 1 to number of items in selectionList
set selectedItem to item i of the selectionList
set selectedPath to POSIX path of (selectedItem as text)
do shell script "rm -rf \"" & selectedPath & "\""
on error error_msg
display dialog "Can't delete " & selectedPath & " due to: " & error_msg Â
with icon 1 Â
default button IGNORE_MSG
set button_pressed to button returned of result
if button_pressed is ABORT_MSG then
return 0
-- by pass
end if
end try
end repeat
return 0
return 0
end if
return 0
end if
end tell
on error error_message
display dialog error_message Â
with title Â
"Error" buttons {"OK"} default button 1
set the clipboard to error_message
end try