rebol [ Author: Robert M. Mnch Site: http://www.robertmuench.de ] ; where are our MBS files stored? root: make block! [%/Users/robby/tmp/] ; we need file access secure [file allow] ; to support multiple runs if exists? mbox: %mail_app/opera.mbox [delete mbox] ; lets walk the directory hierarchy foreach dir root [ foreach sub-entry read dir [ either dir? join dir sub-entry [ ; add directory to the end of the list we just traverse append root dirize join dir sub-entry ] [ ; lets make the correct path to the file f: join dir sub-entry ; we are only interested in MBS files if (suffix? f) == %.mbs [ ; not sure if we should read the file read-file: false ; get file infos like date, size etc. to determine of file should be read finfo: info? f ; for each different account we only import files older than a specific date case [ found? find f %account1/ [if finfo/date < 16-Aug-2008/13:31 [read-file: true]] found? find f %account3/ [if finfo/date < 28-Jan-2009/08:34 [read-file: true]] found? find f %account4/ [if finfo/date < 02-Sep-2008/10:13 [read-file: true]] found? find f %account5/ [if finfo/date < 18-Aug-2008/11:40 [read-file: true]] found? find f %account6/ [if finfo/date < 16-Aug-2008/13:21 [read-file: true]] found? find f %account8/ [if finfo/date < 16-Aug-2008/13:21 [read-file: true]] found? find f %account11/ [read-file: true] found? find f %account12/ [read-file: true] ] ; read condition fullfilled? if read-file [ ; inform user print ["Appending file" f] ; read file as single lines msg: read/lines f ; get rid of additional information in the From_ line, this is Rebol magic ; 1st we split the line by space (parse) ; 2nd remove the additional information is the last entry in the result block of parse (remove back tail) ; 3rd move to the beginning of the block (head) ; 4th make a string incl. spaces out of it (form) ; 5th and assign back to line 1 (msg/1) msg/1: form head remove back tail parse msg/1 "" ; now lets write it to our mbox file write/lines/append mbox msg ; and ensure correct separators between mails write/append mbox #{0A0A} ] ] ] ] ] ; back to user command line halt