Automatically delete a folder daily Is there a way to automatically have a folder deleted every day at 4am?

I'm running 10.6.7.
Appplescript &amp; iCal

Open Applescript and enter the following code:

tell application "Finder"
  delete folder "folder" of home
end tell


Replacing folder with the folder you want to delete, and save the file.

If the folder you want to delete is outside home directory, (for example the folder /Users) then replace the delete line with:

delete folder "Users" of startup disk


Then open iCal and create a new recurring event at the time you want and as an alarm choose Run Script and select the applescript you created.



Cron

Open Terminal.app and enter:

crontab -e


There to the file opened, add the following line

0    4       *       *       *       rm -rf /Users/USER/folder


replacing /Users/USER/folder with the full path of your folder and save the file.



Launchd

Create a new text document, and paste the following code:

rm -rf /Path/to/Folder


Let's call it script.sh

Based on this article, create another new text document and paste the following:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;Recurring Folder Deletion&lt;/string&gt;
  &lt;key&gt;UserName&lt;/key&gt;
  &lt;string&gt;nuc&lt;/string&gt;
  &lt;key&gt;Program&lt;/key&gt;
  &lt;string&gt;/path/to/script.sh&lt;/string&gt;
  &lt;key&gt;StartCalendarInterval&lt;/key&gt;
  &lt;dict&gt;
    &lt;key&gt;Minute&lt;/key&gt;
    &lt;integer&gt;0&lt;/integer&gt;
    &lt;key&gt;Hour&lt;/key&gt;
    &lt;integer&gt;4&lt;/integer&gt;
  &lt;/dict&gt;
  &lt;key&gt;Debug&lt;/key&gt;
  &lt;false/&gt;
  &lt;key&gt;AbandonProcessGroup&lt;/key&gt;
  &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Replace nuc with your account username, and /path/to/script.sh with the full path of the script we created on first step.

Save the file in /Library/LaunchDaemons/ as my_rfd.plist.

Finally, launch Terminal.app and type:

launchctl load /Library/LaunchDaemons/my_rfd.plist