• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
path to cleanup at startup folder'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Prev by Date: Re: Scripting Additions: Embracing the Horror of Unix
  • Next by Date: Run script before sleeping?
  • Previous by thread: Re: Menu Contents?
  • Next by thread: Run script before sleeping?
  • Index(es):
    • Date
    • Thread