home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / wwwos2.zip / bkmk2asc.cmd < prev    next >
OS/2 REXX Batch file  |  1998-07-31  |  8KB  |  196 lines

  1. /* Copyright (c)1997 Kari Jackson for InnoVal Systems Solutions, Inc. */
  2.  
  3. /*---------------------------------------------*/
  4. /* Export NetExtra or WebWilly bookmarks to a  */
  5. /* text file for import into the opposite      */
  6. /* program or another installation of the same */
  7. /* program.                                    */
  8. /*---------------------------------------------*/
  9. /* Instructions:                               */
  10. /* To export one folder, specify that folder's */
  11. /* complete pathname as BKMK2ASC.CMD's command */
  12. /* line argument.  Or to export all of the     */
  13. /* folders at once, execute without arguments  */
  14. /* while the program's BOOKS subdirectory is   */
  15. /* the session's current directory.  Either    */
  16. /* way, the bookmarks will be exported into a  */
  17. /* file named BOOKMARK.ASC in the current      */
  18. /* directory.  ASC2BKMK.CMD can then create    */
  19. /* WebWilly or NetExtra bookmarks from that    */
  20. /* text file.                                  */
  21. /*---------------------------------------------*/
  22. call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  23. signal on syntax name NoREXX
  24. call SysLoadFuncs
  25. signal on syntax name Syntax
  26. "@ECHO OFF"
  27. parse upper arg args
  28. testdir=args
  29. if testdir="" then testdir=translate(directory())
  30. parse var testdir before "\BOOK" after
  31. if after="S" | left(after,2)="S\" then do
  32.    neticon=stream(before"\neticon.dll","c","query exists")
  33.    pgevalid=stream(before"\pgevalid.dll","c","query exists")
  34.    webdate=stream(before"\webdate.dll","c","query exists")
  35.    if neticon="" & pgevalid<>"" & webdate<>"" then fromprog="WEBWILLY"
  36.    if neticon<>"" & pgevalid="" & webdate="" then fromprog="NETEXTRA"
  37. end
  38. if fromprog="FROMPROG" then do
  39.    say ""
  40.    say "Input WebWilly for Windows, or NetExtra/WebWilly for OS/2 format?  (W/O)"
  41.    do until answer="W" | answer="O"
  42.       answer=translate(sysgetkey())
  43.    end
  44.    if answer="O" then fromprog="NETEXTRA"
  45.    else fromprog="WEBWILLY"
  46. end
  47. if args<>"" then do
  48.    call sysfiletree args,"folders.","O"
  49.    if folders.0<>1 then do
  50.       say ""
  51.       say "There are either zero or multiple directories named" args"."
  52.       say "Please type one single existing directory name."
  53.       exit
  54.    end
  55.    foldername=substr(folders.1,lastpos("\",folders.1)+1)
  56.    if fromprog="NETEXTRA" then call SysGetEA folders.1,"WEBEXFOLDERNAME","title"
  57.    else do
  58.       title=""
  59.       do while lines(folders.1"\"foldername".ES")
  60.          title=linein(folders.1"\"foldername".ES")
  61.       end
  62.       if stream(folders.1"\"foldername".ES")<>"UNKNOWN" then call lineout folders.1"\"foldername".ES"
  63.    end
  64.    if title="" then title=foldername
  65.    folders.1=folders.1 title
  66. end
  67. else do
  68.    currdir=directory()
  69.    if translate(right(currdir,6))<>"\BOOKS" then do
  70.       say
  71.       say "Please execute this program from within WebWilly's or NetExtra's BOOKS"
  72.       say "subdirectory or else specify the full path to the folder to be exported."
  73.       exit
  74.    end
  75.    folders.0=0
  76.    filename="fldindex.nix"
  77.    do while lines(filename)
  78.       line=linein(filename)
  79.       parse var line dirname "09"x title "09"x parent "09"x .
  80.       if fromprog="NETEXTRA" then call SysGetEA parent"\"dirname,"WEBEXFOLDERNAME","chktitle"
  81.       else do
  82.          chktitle=""
  83.          do while lines(parent"\"dirname"\"dirname".ES")
  84.             chktitle=linein(parent"\"dirname"\"dirname".ES")
  85.          end
  86.          if stream(parent"\"dirname"\"dirname".ES")<>"UNKNOWN" then call lineout parent"\"dirname"\"dirname".ES"
  87.       end
  88.       if chktitle="" then chktitle=title
  89.       folders.0=folders.0+1
  90.       number=folders.0
  91.       folders.number=parent"\"dirname chktitle
  92.    end
  93.    if stream(filename,"c","query exists")<>"" & stream(FILENAME)<>"UNKNOWN" then call lineout FILENAME
  94.    drop currdir filename line dirname title parent number
  95.    call sysfiletree "*.*","dirs","DSO"
  96.    do i=1 to dirs.0
  97.       folders.0=folders.0+1
  98.       number=folders.0
  99.       foldername=substr(dirs.i,lastpos("\",dirs.i)+1)
  100.       drop title
  101.       if fromprog="NETEXTRA" then call SysGetEA dirs.i,"WEBEXFOLDERNAME","title"
  102.       else do
  103.          title=""
  104.          do while lines(dirs.i"\"foldername".ES")
  105.             title=linein(dirs.i"\"foldername".ES")
  106.          end
  107.          if stream(dirs.i"\"foldername".ES")<>"UNKNOWN" then call lineout dirs.i"\"foldername".ES"
  108.       end
  109.       if title="" then title=foldername
  110.       folders.number=dirs.i title
  111.    end
  112.    drop dirs. number title
  113. end
  114. outfile="bookmark.asc"
  115. do i=1 to folders.0
  116.    call lineout outfile, ""
  117.    call lineout outfile, center(subword(folders.i,2),80)
  118.    call lineout outfile, center(word(folders.i,1),80)
  119.    call lineout outfile, center(copies("-",60),80)
  120.    call sysfiletree word(folders.i,1)"\*.URL","files","FT"
  121.    do j=1 to files.0
  122.       parse var files.j y "/" mo "/" d "/" h "/" min size attrib name
  123.       name=strip(name)
  124.       if fromprog="WEBWILLY" then do
  125.          currentfolder=word(folders.i,1)
  126.          spot=lastpos("\",currentfolder)
  127.          foldername=substr(currentfolder,spot+1)
  128.          if translate(name)=translate(currentfolder||"\"||foldername||".URL") then iterate
  129.          eas=""
  130.          do while lines(name)
  131.             eas=linein(name)
  132.          end
  133.          if stream(name)<>"UNKNOWN" then call lineout name
  134.          if eas="" then iterate
  135.       end
  136.       else do
  137.          call SysGetEA name,"URLFILEBUFFER","eas"
  138.          if eas='' then iterate
  139.       end
  140.       parse var eas . "17"x title "09"x url "09"x date "09"x time "09"x sticky "09"x . "09"x userid "09"x password "09"x .
  141.       if length(date)=5 then do
  142.          if wordpos(y,"96 97 98 99")>0 then y="19"||y
  143.          else y="20"||y
  144.          date=y||"/"||date
  145.       end
  146.       if length(date)=8 then do
  147.          parse var date mm "/" dd "/" yy
  148.          if yy>95 then yy="19"yy
  149.          else yy="20"yy
  150.          date=yy"/"mm"/"dd
  151.       end
  152.       if fromprog="NETEXTRA" & sticky="01"x then do
  153.          call SysGetEA name,"STICKEYDATE","stickydate"
  154.          call sysgetea name,"STICKEYTEXT","stickytext"
  155.          call sysgetea name,"STICKEYFOLLOWUP","stickyfollowup"
  156.          check=""
  157.          do until stickytext=""
  158.             parse var stickytext this "0D"x stickytext
  159.             this=translate(this," ","0A"x)
  160.             if strip(this)="" then iterate
  161.             if check="" then check=strip(this)
  162.             else check=check||"09"x||strip(this)
  163.          end
  164.          stickytext=check
  165.       end
  166.       else if sticky="01"x then do
  167.          stickyfollowup=0
  168.          stickycontents=""
  169.          stickyfile=substr(name,1,lastpos(".",name))||"STK"
  170.          do while lines(stickyfile)
  171.             stickyline=linein(stickyfile)
  172.             if strip(stickyline)="" then iterate
  173.             if stickycontents="" then stickycontents=stickyline
  174.             else stickycontents=stickycontents||"09"x||stickyline
  175.          end
  176.          if stream(stickyfile)<>"UNKNOWN" then call lineout stickyfile
  177.          parse var stickycontents stickydate 9 stickytext
  178.       end
  179.       if stickytext="STICKYTEXT" then stickytext=""
  180.       if stickydate="STICKYDATE" then stickydate=""
  181.       if stickyfollowup="STICKYFOLLOWUP" then stickyfollowup=""
  182.       call lineout outfile, title||"09"x||url||"09"x||date||"09"x||time||"09"x||sticky||"09"x||userid||"09"x||password||"09"x||stickydate||"09"x||stickyfollowup||"09"x||stickytext
  183.    end
  184. end
  185. exit
  186. Syntax:
  187.   say "Error" rc": " errortext(rc)
  188.   say "Line" sigl": " sourceline(sigl)
  189.   exit
  190. return
  191. NoREXX:
  192.    say "Unable to load the REXXUtil functions.  Either the REXXUTIL.DLL file"
  193.    say "is not on the LIBPATH or REXX support is not installed on this system."
  194.    exit
  195. return
  196.