Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!network.ucsd.edu!weber!jon From: jon@weber.ucsd.edu (Jon Matousek) Newsgroups: comp.sys.mac.apps Subject: Re: Nisus Macros: Question and Call for Distribution Summary: Here's one solution to try out. Keywords: macros nisus deleting files Message-ID: <2987@network.ucsd.edu> Date: 26 Sep 90 18:08:51 GMT References: <1990Sep24.113353.121@vax5.cit.cornell.edu> Sender: news@network.ucsd.edu Reply-To: jon@weber.ucsd.edu (jOn mAtOUsEk) Organization: Paragon Concepts, Inc. Lines: 87 Nntp-Posting-Host: weber.ucsd.edu In article <1990Sep24.113353.121@vax5.cit.cornell.edu> pv9y@vax5.cit.cornell.edu writes: ]I have a question about Nisus Macros and the Programming Dialect. I ]want to create a macro that will delete all of my secondary ]automatically ]backups from the Backups folder in which they alone are stored. I have ]a macro in the Macro Dialect which does what I want, open the Catalog ]at the right place, select the first file, choose Delete, and hit ]return to confirm the deletion. It looks like the following... ] ]Catalog "Perseus:Nisus:Backups" "C" ]Catalog ]Select All ]Delete ]Key ] ]Not too difficult, really. However, as soon as I try to make it loop ]using a labelname and a Goto labelname command from the Programming ]Dialect, it fails. I also tried another version which copied the list ]of files from the Catalog, added quotes around each name, the Delete ]command at the beginning of the line, and a Key (hit return) command ]on the next line. It put all this in a new file, selected it, and then ]Executed Selection. It too only worked with a single file and wouldn't ]confirm any of them if there were more than one. Ideally I would like ]to enhance this at some point to delete all the backups that are more ]than a week old and have it do that at startup each day. Otherwise I ]have to remember to manually delete the 500K or so that builds up ]every few weeks. ] ]Any ideas on how this can be made to work? Thanks ... Is the "Nisus Programming Dialect" module in the same folder as Nisus, if not you will have to load it manually. Here is something I quickly worked out to delete files that are older than 1 week old. I'll leave it up to you to test it. Catalog "Perseus:Nisus:Backups" "C" Catalog Select All // calculate when one week ago from now is (all in seconds). oneWeekAgo = date - (3600 * 24 * 7) // save all of the file names on a stack named "s". s -> push (strings) // loop over every filename in the stack, exit when the stack is empty. loop: if (!s -> size) exit // open the file so we can get the date when saved. clipboard = s -> pop open '\CC' dateSaved = LastDateSaved close // compare the dateSaved to one week ago, do nothing if newer than a week. if (dateSaved > oneWeekAgo) goto loop // else delete this file, it's older than a week. (Its Key below.) Find Next '\CC' "-goW" Delete Key goto loop ] ]...Adam ] ]-- ]Adam C. Engst pv9y@vax5.cit.cornell.edu ]--------------------------------------------------------------- ]Editor of TidBITS, the weekly electronic Macintosh news journal Hope this helps, -jOn -------------------------------------------------------------------------- %% SoftwareEngineer: jOn mAtOUsEk; Internet: jon@weber.ucsd.edu %% AppleLink: D0405 Paragon Concepts, Inc. FAX: (619)481-6154 990 Highland Drive, #312 Solana Beach, Ca. 92075 (619)481-1477 ==========================================================================