Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 65 lines (59 sloc) 1.739 kB
a8f9d2f @trung First working version
authored
1 (*
2 Author: Nguyen Kien Trung
3 This script is to delete files permanently without Trashing.
4 Interactive dialog is displayed for user to confirm the action.
5 Works on Leopard
6 *)
7
3dbcca2 @trung Update readme
authored
8 property parent : application "Finder"
a8f9d2f @trung First working version
authored
9
10 set OK_MSG to "Sure, I am"
11 set CANCEL_MSG to "Sorry, I ain't"
12 set ABORT_MSG to "Abort, safety first"
13 set IGNORE_MSG to "Pass, try next one"
14
15 try
3dbcca2 @trung Update readme
authored
16 tell application "Finder"
a8f9d2f @trung First working version
authored
17 activate
18 set selectionList to get selection as list
19 set selectionCount to count items in selectionList
3dbcca2 @trung Update readme
authored
20
21 set asking_dialog to display dialog "There are " & selectionCount & Â
22 " selected folders/files.
23 Are you sure to delete permanently?" with title Â
24 "Warning" with icon stop Â
25 buttons {CANCEL_MSG, OK_MSG} Â
a8f9d2f @trung First working version
authored
26 default button CANCEL_MSG
27 set button_pressed to button returned of result
28
29 if button_pressed is OK_MSG then
30 if selectionCount > 0 then
31 repeat with i from 1 to number of items in selectionList
32 set selectedItem to item i of the selectionList
33 set selectedPath to POSIX path of (selectedItem as text)
34 try
35 do shell script "rm -rf \"" & selectedPath & "\""
36 on error error_msg
37 beep
3dbcca2 @trung Update readme
authored
38 display dialog "Can't delete " & selectedPath & " due to: " & error_msg Â
39 with icon 1 Â
40 buttons {ABORT_MSG, IGNORE_MSG} Â
a8f9d2f @trung First working version
authored
41 default button IGNORE_MSG
42 set button_pressed to button returned of result
43 if button_pressed is ABORT_MSG then
44 return 0
45 else
46 -- by pass
47 end if
48 end try
49 end repeat
50 return 0
51 else
3dbcca2 @trung Update readme
authored
52 return 0
a8f9d2f @trung First working version
authored
53 end if
54 else
55 return 0
56 end if
57 end tell
58 on error error_message
59 beep
3dbcca2 @trung Update readme
authored
60 display dialog error_message Â
61 with title Â
62 "Error" buttons {"OK"} default button 1
a8f9d2f @trung First working version
authored
63 set the clipboard to error_message
3dbcca2 @trung Update readme
authored
64 end try
Something went wrong with that request. Please try again.