path to cleanup at startup folder'
path to cleanup at startup folder'
- Subject: path to cleanup at startup folder'
- From: email@hidden
- Date: Fri, 1 Feb 2002 23:03:29 EST
Certainly there is. You need to write (or implement) a simple script that:
(a) checks to see if the folder is empty;
(b) if it isn't, moves the contents to the trash;
and
(c) empties the trash.
tell application "Finder"
set XferToTrashPath to (path to trash) as alias
if folder ("HD_name:Cleanup At Startup") exists then
set Cleanuppath to ("HD_name:Cleanup At Startup:") as alias
-- grab a list of all the files in the folder
set ListOFiles to list folder Cleanuppath
if ListOFiles is not {} then
repeat until ListOFiles is {}
-- grab the first item in the folder
set CurrentFileToTrash to ((Cleanuppath as string) & first
item in ListOFiles as string)
-- and move the file to the trash (note: moveFile is from
Jon's commands)
moveFile CurrentFileToTrash to XferToTrashPath
set ListOFiles to list folder Cleanuppath -- reset the list
end repeat
end if -- end if ListOFiles is not empty
end if -- end if MRJ Cache folder exists
end tell
tell application "Finder"
empty trash
end tell
Note that this script uses the moveFile command from Jon's commands (an
scripting library add-on). I haven't figured out how to make the finder move
files without Jon's commands [yet]. The call to empty the trash is done a
separate tell in the same script to prevent timing issues where AppleScript
attempted to get ahead of itself.
Also of note: if there is anything else in the trash, it will be gone too...
=-= Marc
Brennan <email@hidden> wrote:
>
Is there a reliable way to get at the 'cleanup at
>
startup' folder (I'm thinking of something like 'path
>
to temporary items').
>
>
If I put something in 'temporary items', there's no
>
way I can have it cleaned up automatically is there?
>
>
Thanks in advance.