I modified mysterytramp's and Wondersnite's code to allow one to delete a number of files (or just one file) from the trash. I found it to be kind of annoying to keep having to answer, yes, if I wanted to delete two or more files, for each file.
Code:tell application "Finder" if button returned of (display dialog "Are you sure you want to permanently delete these files?" buttons {"Yes", "No"} default button "No") is "Yes" then get the selection if the number of items of the result < 1 then beep else repeat with theFile in the result set theVolume to the disk of theFile set itemPath to the (theFile as text) if ":.Trash" is in itemPath then do shell script "rm -r " & (quoted form of POSIX path of itemPath) else beep end if end repeat end if end if end tell
Thank you -aggie-, this code is just perfect. I also checked and it even works if you are deleting items from various volumes. Now it works exactly as it should
Code:
tell application "Finder"
set theSelection to the selection
if the number of items of theSelection < 1 then
beep
else
if button returned of (display dialog "Are you sure you want to permanently delete these files?" buttons {"Yes", "No"} default button "No") is "Yes" then
repeat with theFile in theSelection
set itemPath to the (theFile as text)
if ":.Trash" is in itemPath then
do shell script "rm -r " & (quoted form of POSIX path of itemPath)
else
beep
end if
end repeat
end if
end if
end tell
I've using this with Spark, it works flawlessly