Skip to content
Browse files

First working version

  • Loading branch information...
0 parents commit a8f9d2f5a6017df49ef0ed390541942bf75ef11d @trung committed Feb 24, 2010
Showing with 68 additions and 0 deletions.
  1. +63 −0 PDelete.applescript
  2. +5 −0 README
63 PDelete.applescript
@@ -0,0 +1,63 @@
+(*
+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
+*)
+
+prop parent : app "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"
+
+try
+ tell application "Finder"
+ activate
+ 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. \nAre 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)
+ try
+ do shell script "rm -rf \"" & selectedPath & "\""
+ on error error_msg
+ beep
+ display dialog "Can't delete " & selectedPath & " due to: " & error_msg ¬
+ with icon 1 ¬
+ buttons {ABORT_MSG, IGNORE_MSG} ¬
+ default button IGNORE_MSG
+ set button_pressed to button returned of result
+ if button_pressed is ABORT_MSG then
+ return 0
+ else
+ -- by pass
+ end if
+ end try
+ end repeat
+ return 0
+ else
+ return 0
+ end if
+ else
+ return 0
+ end if
+ end tell
+on error error_message
+ beep
+ display dialog error_message ¬
+ with title "Error" ¬
+ buttons {"OK"} default button 1
+ set the clipboard to error_message
+end try
5 README
@@ -0,0 +1,5 @@
+Applescript Utility to delete files permanently without going thru Trash.
+
+Tested on Mac OS 10.5 Leopard
+
+Supported FileVault, USB Volume

0 comments on commit a8f9d2f

Please sign in to comment.
Something went wrong with that request. Please try again.