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


Click here to return to the 'Selectively shred files with an Applescript droplet' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Selectively shred files with an Applescript droplet
Authored by: dbingham on Apr 07, '06 05:43:28PM
Re: Krioni's improvements

This isn't quite correct:

		if length of filePaths is 0 then
			set filePaths to filePaths & quoted form of POSIX path of n_file & space
			set fileVerticalList to fileVerticalList & POSIX path of n_file & return
		else
			set filePaths to filePaths & quoted form of POSIX path of n_file
			set fileVerticalList to fileVerticalList & POSIX path of n_file
		end if
If there are more than 2 files, it won't work! Try this instead:

		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
So, the whole script would now be:

(*
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
*)


--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 the files in the current user's trash
on run
	set x to display dialog "Do you want to permanently shred (delete by overwriting) all the files in your trash?" buttons {"Yes", "No"} default button "No"
	if button returned of x is "Yes" then
		try
			do shell script command & "~/.Trash/*"
		end try
		--update trash icon in the dock
		tell application "Finder" to update trash
	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 "echo '" & command & filePaths & "' > ~/test.txt"
		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 | # ]
Selectively shred files with an Applescript droplet: correction
Authored by: dbingham on Apr 07, '06 05:47:16PM
Oops. Left some debugging code in there. This is correct:


(*
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
*)


--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 the files in the current user's trash
on run
	set x to display dialog "Do you want to permanently shred (delete by overwriting) all the files in your trash?" buttons {"Yes", "No"} default button "No"
	if button returned of x is "Yes" then
		try
			do shell script command & "~/.Trash/*"
		end try
		--update trash icon in the dock
		tell application "Finder" to update trash
	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 | # ]