Secure Erase Apple Script

Hi Guys

Im new to the forum, and would really appreciate some help with a code call that i am trying to implement.

I want to call Secure Erase of Trash Via AppleScript.

I have done a search on this site and cannot find anything :frowning:

Im assuming you would call finder

tell application “Finder”

empty the Trash

end tell

But Where would you put the secure call?

Cheers

If you look at the dictionary of the Finder you’ll find this at the command empty

so your applescript will look like this:

tell application "Finder"
	empty trash with security
	-- applescript automaticly compiles a true parameter with "with"
	-- actually you type "empty trash security true"
end tell

or even shorter

tell application "Finder" to empty with security

hope it works,
ief2

Many Thanks Guys Much Appreciated!!!

One other question though

the with security, How secure is it? can you specify how many times it writes over the data?

Cheers

once, it removes the entry from the directory and sets the bytes of all allocated memory blocks to zero.
It’s an urban legend to get more security while overwriting 2 or more times. Digital data are digital data

Hey Guys,

i Just Tried running the script, it started, however, i walked away for 5 minutes came back and it said that the application had timed out… , however the erase was still running , any ideas?

Cheers

I think (but I’m not sure) this happens because it’s taking way too long until the Finder gives a response according to applescript. I read some other applescripts with the use of with timeout of ., but I never used it before and I do not have a single idea how it works. I guess it has to be something like this:

with timeout of 1800 seconds
	tell application "Finder" to empty with security
end timeout

But can’t you solve the problem by using the shell script?

hope it helps,
ief2

Cheers for the fast responce, as to our question regards shell:

do shell script “srm -fR ~/.Trash/*”

I’m Guessing:
SRM = Secure Remove
/.Trash/* = Delete All Items in Trash

What I am Not Sure About Though is the Switches that have been used

-fR

Cheers

if you type “srm --help” in the terminal you get this:

So I guess, but I’m not sure, fR stands for a combination of f and R

hope it helps,
ief2

Just tried it with this

srm -rmf ~/.Trash/*

Works a Treat! Cheers

Hey guys,

i am using:

srm -rmf ~/.Trash/*

in my applescript. The only thing is that it still allows access to the trash while it is running.

One thing i am trying is to get my script to load up terminal and get it to write the above and execute

any ideas

i know how to open, but am having issues getting it to write to the terminal


tell application "Terminal"
	do script "pwd" -- change to your specific command
end tell

Hi Craig

I can’t get that to work

 
tell application "Terminal"
	do script srm -vrmf ~/.Trash/* -- change to your specific command
end tell
 

any ideas? cheers

I don’t know, but you did execute it with the “.”?:

tell application "Terminal"
   do script "srm -vrmf ~/.Trash/*" -- change to your specific command
end tell

I think that is necessary

hope it works,
ief2

Cheers IEF2!!

There should be some kind of kudos feature here, appreciate all the help!

Is there anyway of getting the terminal to close once it has finished doing the erase?