Destructive scripting.

Help. I need a script that can help me remove some pirated software from some of my users systems. A very simple script that would delete specific folders from the Applications folder, specific files from the preferences folder, and then empty the trash.

I’m close but I havent used applescript for years. How do you specify a folder or file to be moved?

Thanks

I’m pretty new to apple scripting, but looking at a script that we use around the office, it looks like deleting files is done like so:

select file “OS:Applications:QuarkXPress 6.1:XTension:Suitcase XT6 (US).xnt”
delete selection

I hope that helps.

I believe that you would need the Finder to make a selection.
Finder can also delete without selecting.

This may be what you want for a folder
tell application “Finder” to delete “HD:Applications:QuarkXPress 6.1:”

Note the path of a folder ends in “:”

For a file
tell application “Finder” to delete “HD:Applications:QuarkXPress 6.1:XTension:Suitcase XT6 (US).xnt”

Note that path of a file ends without “:”

:stuck_out_tongue:

thanks guys. It’s starting to come together. How do I specify multple folders in the same parent?

Here is one way but not necessarily the best way.

property folders_ToDelete : {“Untitled folder”, “Untitled folder 2”}
property parent_Folder : {“HD:Applications:Parent Folder:”}

tell application “Finder”
repeat with i from 1 to count of folders_ToDelete
delete ((parent_Folder as text) & (item i of folders_ToDelete as text)) & “:”
end repeat
end tell

Where HD is the name of you Hard Drive and Parent Folder is the name of the Parent Folder.