// E-XTRACT- Extract all e-mail addresses from a file, sort them // and remove duplicates. // Works well with Thunderbird .MAB files, that is to say // with Mozilla Address Book files. // // Originally by: Ted Green, Greenview Data, Inc. // Last change: 10/18/98 // 10/22/2006 // // Requires: VEDIT 5.00 or later. // // From VEDIT: Select {MISC, Load/Execute macro}. Enter filename // "e-xtract.vdm". Use default register number "100". // // At the prompt, enter the source and destination // filenames. // // From OS: vpw -x e-xtract.vdm // // WILDFILE: This macro can be run from WILDFILE to extract e-mail // addresses from entire groups of files. In this case it // only prompts once for the destination filename. // // Note: This macro works well for extracting e-mail addresses // from a database file, in particular, it works .mab files. // That is to say, for Thunderbird address book files. Do not // use it with e-mail archive files or you will get many useless routing // addresses; use E-EMAIL.VDM instead. // #18 = Buf_Num //#18 = original buffer # Reg_Set(11,"email.mbx") //Default source filename //Reg_Set(12,"email.txt") //Default destination filename Reg_Set(12,PATHONLY) // PR 10-22-2006; Edited default // destination filename Reg_Set(12,"\",APPEND) Reg_Set(12,FILEONLY,APPEND) Reg_Set(12,".",APPEND) Reg_Set(12,"lst",APPEND) // PR 10-22-2006. Default destination filename if ((#99==0x57495C44) && (#19==0x452D5854)) { //If WILDFILE running and //destination file selected... #11 = Buf_Num //#11 = source buffer # Goto RUN } Win_Clear() Message(` ***************************************** * E-XTRACT.VDM - 10/18/98 * * Extract all e-mail addresses * ***************************************** `) // PR: 10-22-2006, Added "all" if ((#99==0x57495C44)) { Goto NEWDESTINATION } //If WILDFILE and 1st time in... if (Is_Open_Write && Filesize ) { Goto NEWDESTINATION } //If file already open // :NEWSOURCE: Get_Input(11,"\nEnter source filename: ",@11,NOCR) if (File_Exist(@11)==0) { Alert() Message("File not found. Try again.\n") Goto NEWSOURCE } File_Open("|@(11)") // :NEWDESTINATION: Get_Input(12,"\nEnter destination filename: ",@12,NOCR) // // If file exists, prompt to overwrite, append or get new name. // if (File_Exist(@12)) { Alert() Message(" File already exists! [O] Overwrite it [A] Append to it [N] Get new filename [C] Cancel macro Enter desired option: ") repeat (ALL) { #10=Get_Key("")&0xFFDF if (#10=='O' || #10=='A' || #10=='N' || #10=='C') { Break } Alert() } Type_Char( Previous_Key(0) ) if (#10=='N') { Goto NEWDESTINATION } if (#10=='O') { File_Delete(@12,OK) } if (#10=='C') { Return } } #11 = Buf_Num //#11 = source buffer # #12 = Buf_Free() //#12 = destination buffer Buf_Switch(#12) //Switch to destination buffer File_Open("|@(12)") //Open destination file EOF() //Goto end of it #19=0x452D5854 //Flag the E-XTRACT.VDM fully set up // // :RUN: Buf_Switch(#11) //Switch to the source buffer Begin_Of_File //Start at beginning of file // // Process each search occurrence. // Message("\nSearching for e-mail addresses...") repeat(ALL) { //Repeat forever until Search() breaks out Search("[a-zA-Z0-9\_\-\.]+@[a-zA-Z0-9\_\-\.]+\.[a-zA-Z][a-zA-Z][a-zA-Z]?",REGEXP+MAX+ADVANCE+ERRBREAK) Reg_Copy_Block(14,CP-Chars_Matched,CP) // Copy e-mail address to T-Reg 14 Buf_Switch(#12) //Switch to destination file Reg_Ins(14) //Insert (append) the address Ins_Newline() //Followed by a Newline (CR+LF) Buf_Switch(#11) //Back to the source file } Buf_Switch(#12) //Switch to destination file // // Delete specific unwanted e-mails. // Setup for Greenview Data. YOU WILL WANT TO CHANGE THIS. // Message("\nDeleting unwanted e-mail addresses...") BOF repeat(ALL) { Search("@vedit.com",ERRBREAK) BOL Del_line() } BOF repeat(ALL) { Search("veditcom",ERRBREAK) BOL Del_line() } BOF repeat(ALL) { Search(".netlimited.net",ERRBREAK) BOL Del_line() } BOF repeat(ALL) { Search(".dundee.net",ERRBREAK) BOL Del_line() } BOF repeat(ALL) { Search(".msen.com",ERRBREAK) BOL Del_line() } // // Sort e-mail addresses and remove duplicates. // Message("\nSorting e-mail addresses...") Replace('"',"",REVERSE+ALL+NOERR) //Remove double-quotes Sort(0,File_Size) //Sort entire file // Message("\nDeleting duplicate e-mail addresses...") BOF repeat(ALL) { //Search & delete duplicate lines Search("^{.*}\N\1$",REGEXP+MAX+ERRBREAK) Del_line() } // // :DONE: if (#99!=0x57495C44) { //If WILDFILE not running, prompt... #19=0 //Clear "E-XTRACT.VDM setup" flag if (File_Size < 1000000) { Begin_Of_File } // Go to beginning if small file Update() //Show the destination file while ((#10=Get_Key("\nSave extracted file? [Y]es [N]o-abandon [C]ancel")&0xFFDF)!='Y' && #10!='N' && #10!='C') { Alert } //Wait for valid reply if (#10=='Y') { Buf_Close(NOMSG) //Save file and close buffer Buf_Switch(#18) //Back to original file Return } if (#10=='N') { Buf_Quit(OK) //Abandon file and close buffer Buf_Switch(#18) //Back to original file Return } }