Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Pick a file to shred (on run)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Pick a file to shred (on run)
Authored by: rshrinivas on Apr 18, '07 11:02:57AM
Using a file selection dialog, ... if some files in the trash cause too much angst, pick them :)
----------
(*
Author: Jayson Kempinger
E-mail: evilglowingapple@gmail.com
Date created: 23 April 2005

Permantly Shred script
Drop files/folders onto this as an application. This script will shred the files
using the command specified in property command.

Icon modified from origional e.shred.gif at http://www.lebofsky.com/write/hailstorms.html

-- some modifications by Dan Shockley (http://www.danshockley.com)
-- some more modifications by dbingham
-- minor addition by rshrinivas
*)


--command to shred files. Use shred if you have it installed, use "rm -rfP " if you do not
property command : "rm -rfP "

--when running the app not as a dropplet, shred a user selected file
on run
set x to choose file with prompt "Pick a file to shred" --default value "~/.Trash/"
set fileName to " \"" & POSIX path of x & "\" "
set x to display dialog "Confirm deleting " & fileName & "?" buttons {"Yes", "No"} default button "No"
if button returned of x is "Yes" then
try
do shell script command & fileName
end try
--update finder
tell application "Finder" to update
end if
end run

--shred dropped files
on open target_files
--combine filePaths of all files into one string for subject

set filePaths to "" -- space-separated list of file-paths for the shell command
set fileVerticalList to "" -- retrn-delimited list of file-paths for dialog prompt

repeat with n_file in target_files
set n_file to contents of n_file -- sometimes a "reference" is not a good thing, so
-- let's explicitly set n_file to the

if n_file is last item of target_files then
set fileVerticalList to fileVerticalList & POSIX path of n_file
set filePaths to filePaths & quoted form of POSIX path of n_file
else
set fileVerticalList to fileVerticalList & POSIX path of n_file & return
set filePaths to filePaths & quoted form of POSIX path of n_file & space
end if
end repeat

set x to display dialog "Do you want to permanently shred (delete by overwriting):" & return & fileVerticalList & "?" buttons {"Yes", "No"} default button "No"
if button returned of x is "Yes" then
try
do shell script command & filePaths
end try
--update trash icon in the dock just in case files were from the trash folder
tell application "Finder" to update trash
end if
end open

[ Reply to This | # ]