home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / bookmark.zip / BOOKMARK.CMD next >
OS/2 REXX Batch file  |  1997-02-10  |  2KB  |  103 lines

  1. /*
  2.   REXX Routine to sort Netscape bookmark file
  3.   format:  bookmark f:dsn   ie.,  bookmark c:\ibmnet\bookmark.htm
  4.   original bookmark.htm will be backed up in bookmark.sav.  Do not run exec
  5.   a second time until you have tested Bookmarks using NETSCAPE (ie do not
  6.   destroy your backup file before testing new file).
  7.  
  8.   Note: Output file will be double spaced but will work fine.  Netscape will
  9.         eventually put it back in single spaced mode.  DO NO edit the
  10.         bookmark.htm file.
  11.  
  12.   If you find this program useful do not hesitate to send $15.00 to:
  13.      Ed Huband
  14.      15220 Emory Ln
  15.      Rockville MD 20853
  16.      USA
  17.  
  18.   Changes:
  19.     02/08/97: Original by Ed Huband   <huband@ibm.net>
  20. */
  21.  
  22. trace
  23.  
  24. parse arg dsn
  25. do forever
  26.   if dsn = '' then say 'Please enter full path and dataset name'
  27.     else leave
  28.   pull dsn
  29. end
  30.  
  31. 'echo off'
  32.  
  33. parse value dsn with dsnx '.' .
  34. 'copy ' dsn dsnx'.sav'
  35. if rc <> 0 then exit
  36.  
  37. infile =  dsnx'.sav'
  38. outfile = dsn
  39. 'erase' outfile    /*    clear outfile */
  40.  
  41. i = 0
  42. do forever
  43.   test = lines(infile)
  44.   if test = 0 then leave  /*eof*/
  45.   i=i+1
  46.   inline.i = linein(infile)
  47. end
  48.  
  49. isave = i
  50. inline.0 = i
  51. say isave 'lines in'
  52.  
  53. swapcnt = 0
  54. dot = ''
  55.  
  56. do forever
  57. swap = 'n'
  58.   do i = 1 to inline.0 - 1
  59.     parse upper value inline.i with first1  '>' . '>' rest1
  60.     if first1 <> '    <DT' then iterate
  61.  
  62.     j = i + 1
  63.     parse upper value inline.j with first2  '>' . '>' rest2
  64.     if first2 <> '    <DT' then         /*  check for double spaced */
  65.       do forever
  66.         j = j + 1
  67.         if j > inline.0 then leave
  68.         parse upper value inline.j with first2  '>' . '>' rest2
  69.         if first2 = '    <DT' then leave
  70.       end
  71.  
  72.     if rest1 > rest2 then
  73.       do
  74.         swap = 'y'
  75.         swapcnt = swapcnt + 1
  76.         save = inline.i
  77.         inline.i = inline.j
  78.         inline.j = save
  79.         lastswap = j
  80.       end
  81.   end
  82.   inline.0 = lastswap
  83.   if swap = 'n' then leave
  84.  
  85.   'cls'
  86.   say ''
  87.   say isave 'lines in'
  88.   say ''
  89.   say 'Sorting..please wait'
  90.   dot = dot||'.'
  91.   say dot
  92.  
  93. end
  94.  
  95. say 'Swap Count = 'swapcnt
  96.  
  97. do i = 1 to isave
  98.   call lineout outfile,inline.i
  99. end
  100.  
  101. call lineout outfile  /* close */
  102. exit 0
  103.