Please HELP! I Need an Applescript To Delete Files.

Hey everyone, NOOBIE here.

I need to make an Applescript that will delete 1 file and 2 folders when I execute it.

I run Mac OS 10.3.8 with Quickeys. Once in a while when my Apps crash, I need to delete the .pref file and two database folders before restarting them. It is a hassle to navigate to the files, and delete them.

I am hoping to make an applescript that will do this with one click. Can anyone help me out? I’ve spent a couple days at it, but admittedly, I don’t know what Im doing.

The file is named “com.application.plist”. It is in the Users/Me/Library/Preferences folder of my Macintosh HD startup disk
The 2 folders are named “ApplicationDatabases(one of them is on the root of my Macintosh HD startup disk, the other one is on the root of my second hard drive)

I can do this easily with Automator in 10.4. Unfortunately, Automator doesnt run on OS 10.3

Any suggestions would be greatly appeciated.

Thanks,
Steve

Hi
I am pretty new too but i think the following should work.


tell application "Finder"
delete file "Macintosh HD:Users:Me:Library/Preferences:com.application.plist"
delete folder "Macintosh HD:ApplicationDatabases"
delete folder "whatever is the name of the volume of your second disk:ApplicationDatabases
end tell

do let me know
Rajesh

Rajesh

Thanks! That almost works.

The delete folder command works, but delete file comes up with Applescript error: “Finder got an error: Can’t get file”…"

I think it is becuase it is a preference file within my Library folder.
If I more the file to my User/Me folder then it works.

Any thoughts?

Steve

BTW: Thanks for the Lightning quick reply,

this line should be

delete file “Macintosh HD:Users:Me:Library:Preferences:com.application.plist”

NOT:

delete file “Macintosh HD:Users:Me:Library/Preferences:com.application.plist”

Just a typo - the rest of the script is perfect

That’s IT!

Thanks a million guys.

Steve

Granted your doing a call each time, but this would be my preferred method of doing

set rmList to {¬
	"/Users/Me/Library/Preferences/com.application.plist", ¬
	"/ApplicationDatabases", ¬
	"/Volumes/whatever\\ is\\ the\\ name\\ of\\ the\\ volume\\ of\\ your\\ second\\ disk/ApplicationDatabases"}

repeat with rmItem in rmList
	do shell script "rm -rf " & rmItem
end repeat

or I suppouse your shell script could be building one long “;” seperated list of commands and then you pass them in a single do shell script when done.