hi,
i have a “temp_trash” folder on our server. i want to delete the files in it every two weeks automatically.
do you have a idea how i can do this?
cheers
hi,
i have a “temp_trash” folder on our server. i want to delete the files in it every two weeks automatically.
do you have a idea how i can do this?
cheers
Sounds like a perfect use of a cron job (or launchd on newer systems)
The easiest way to do this is to download the Cronnix app and use that to trigger your applescript/shell script.
Alternitvely - you can launch applescripts from iCal as well - which mught be easier for you.
An easy way to do actually do the deleting with an applescript is:
set theFolder to "Macintosh HD:Users:userfolder:" as alias
tell application "Finder" to delete every file of theFolder
You will need to have this script run on the actual server though - because this just actually moves the files to the trash - and when you do this from a client you will get a dialog box, which you don’t want.
If you want to do it from a client - you may be better off with a shell script.
be careful with this!!! Files will be deleted with NO UNDO and no confirmation!!!
rm -R /path/to/folder
/bin/rm - Always use full paths to prevent potential nastiness.
See my post here on the subject:
thank you very much.
is there any way to delete the files always after two weeks from this date on i had put the files in this folder?
example:
i put a file on the 1. Feb 2006 in this folder then this script should delete this file on the 15. Feb. but all other files which i put after the 1. Feb in this folder should be stay in it.
Try this:
set dir to choose folder
do shell script "/usr/bin/find " & quoted form of POSIX path of dir & " -ctime 14 -exec rm -rf {} \\;"
Here is the definition of -ctime from man find:
-ctime n
True if the difference between the time of last change of file
status information and the time find was started, rounded up to
the next full 24-hour period, is n 24-hour periods.
So it will only delete files that were modified 14 days ago, not older than that.