home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lorautil.zip / INET.CMD < prev    next >
OS/2 REXX Batch file  |  1995-05-08  |  4KB  |  131 lines

  1. /* INET.CMD - REXX program to move Internet Mail from the
  2. Netmail directory to the Internet directory. Skips mail addressed to me.
  3.  
  4. Maybe it's a little kludgy but it works. Hey, whaddya want for free?
  5. ver. 1.0 - 14 January, 1995 by Elliott Goodman, 1:102/1319 
  6.  
  7. Donations for this program may be sent to:
  8.  
  9.      Elliott Goodman        
  10.      PO Box 500038          
  11.      Palmdale, CA 93591-0038
  12.  
  13. */
  14.  
  15. /* check whether RxFuncs are loaded. If not, load them. */
  16.  
  17. if RxFuncQuery('SysLoadFuncs') then
  18. do
  19.    call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  20.    call SysLoadFuncs
  21. end
  22.  
  23. path.1 = 'd:\lora\msg\net'        /* set up directories */
  24. path.2 = '\lora\msg\inet'
  25. path.3 = '\temp'
  26.  
  27. /* Move to Netmail area */
  28. call directory path.1
  29.  
  30. /* use SysFileTree here to check for MSG files */
  31.    call SysFileTree path.1||'\*.MSG', msg_file, 'F'
  32.  
  33.    do i = 1 to msg_file.0          /* cycle thru MSG files */
  34.  
  35. /* get info on each file in the area */
  36.    parse var msg_file.i,
  37.          file_date,
  38.          file_time,
  39.          file_size,
  40.          file_attr,
  41.          file_name
  42.  
  43. /* remove trailing space */
  44.      file_name = strip( file_name )
  45.  
  46. areaname = path.1||'\'
  47.  
  48. /* remove drive/subdir info from filename */
  49.      parse var file_name (areaname) file_name
  50.  
  51. /* convert to caps, just in case */
  52.      file_name = translate( file_name )
  53.  
  54. /* read in first line (actually, the whole message) */
  55.     first_line = linein(file_name)
  56.  
  57. /* close the file so we can move it, if necessary */
  58.     call lineout(file_name)
  59.  
  60. /* truncate to 80 characters */
  61.     first_line = left(first_line, 80)
  62.  
  63. /* uppercase for easy comparison */
  64.     first_line = translate(first_line)
  65.  
  66. /* change nul characters and periods to spaces so we can
  67. search by words */
  68.     first_line = translate(first_line, '  ', x2c('00')||'.')
  69.  
  70. /* look for messages addressed to or from me; skip if found */
  71.     if wordpos('ELLIOTT', first_line) = 0 then do
  72.  
  73. /* otherwise, it's to someone else. Move it to temp directory */
  74.         'move ' file_name path.3
  75.         end /* if wordpos */
  76.     end /* cycling thru msg files */
  77.  
  78. /* change to temp directory */
  79. 'cd ' path.3
  80.  
  81. /* pick a number high enough so as not to overwrite any
  82. existing messages in the Internet area */
  83. new_msg_number = 400
  84.  
  85. /* use SysFileTree here to identify moved msg files */
  86.    call SysFileTree 'd:'||path.3||'\*.MSG', msg_file, 'F'
  87.  
  88.    do i = 1 to msg_file.0 /* cycle thru the moved messages */
  89.  
  90.    parse var msg_file.i,
  91.          file_date,
  92.          file_time,
  93.          file_size,
  94.          file_attr,
  95.          file_name
  96.      file_name = strip( file_name )
  97.      areaname = 'd:'||path.3||'\'
  98.      parse var file_name (areaname) file_name
  99.      file_name = translate( file_name )
  100.  
  101. /* rename (renumber) the moved MSG files */ 
  102.     'ren ' file_name new_msg_number||'.MSG'
  103.     new_msg_number = new_msg_number + 1
  104.  
  105.     end /* renumbering moved MSG files */
  106.  
  107. /* build file list again to get new xxx.MSG names */
  108.    call SysFileTree 'd:'||path.3||'\*.MSG', msg_file, 'F'
  109.  
  110.    do i = 1 to msg_file.0
  111.    parse var msg_file.i,
  112.          file_date,
  113.          file_time,
  114.          file_size,
  115.          file_attr,
  116.          file_name
  117.      file_name = strip( file_name )
  118.      areaname = 'd:'||path.3||'\'
  119.      parse var file_name (areaname) file_name                          
  120.      file_name = translate( file_name )                                 
  121.  
  122. /* now move to Internet Mail area */
  123.     'move ' file_name path.2
  124.     end /* cycling thru renamed MSG's */
  125.  
  126. /* finally, use LMSG to force renumbering and indexing */
  127. 'cd \lora'
  128. 'lmsgb4 -ir -xqspg'
  129.  
  130. exit
  131.