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

  1. /* Create WebWilly for OS/2 bookmarks from OS/2 WPS URL objects */
  2. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  3. signal on syntax name NoREXX
  4. call SysLoadFuncs
  5. signal on syntax name Syntax
  6. '@ECHO OFF'
  7. parse arg indir outfolder
  8. if outfolder='' then do
  9.    say ""
  10.    say "Parameters:"
  11.    say "-----------"
  12.    say "1.  The directory which contains the URL objects from which the"
  13.    say "    bookmarks are to be created."
  14.    say ""
  15.    say "2.  The folder in which the bookmarks are to be created.  Can be the"
  16.    say "    relative pathname of an existing folder; or, if the current"
  17.    say "    directory is the BOOKS subdirectory of your WebWilly directory,"
  18.    say "    then it can be the title or subdirectory name of an existing"
  19.    say "    folder in the BOOKS subdirectory, or the subdirectory name of a"
  20.    say "    folder to create in the BOOKS subdirectory."
  21.    exit
  22. end
  23. call sysfiletree outfolder,'folder','DO'
  24. if folder.0>1 then do
  25.    say ""
  26.    do i=1 to folder.0
  27.       say folder.i
  28.    end
  29.    say ""
  30.    say "Parameter ("outfolder") not understood:"
  31.    say "More than one directory exists with that name."
  32.    exit
  33. end
  34. if folder.0=0 then do
  35.    call sysfiletree '..\LOG','check','DO'
  36.    if translate(right(directory(),6))='\BOOKS' & check.0=1 & pos('\',outfolder)=0 then do
  37.       oldtitle=outfolder
  38.       outfolder=strip(left(translate(outfolder,'',' \|,./<>?;'':"[]{}`-=~!@#$%^&*()+','_'),8))
  39.       outfolder=translate(outfolder,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  40.       call sysfiletree outfolder,'check','DO'
  41.       if check.0=1 then outfolder=check.1
  42.       else do
  43.          say ""
  44.          say "Please enter a title for the new folder ("outfolder"):"
  45.          say "(default: " oldtitle")...."
  46.          parse pull title
  47.          if strip(title)='' then title=oldtitle
  48.          rc=sysmkdir(outfolder)
  49.          if rc>0 then do
  50.             say ""
  51.             say "Unable to create" outfolder "directory."
  52.             exit
  53.          end
  54.          if SysPutEA(outfolder,'WEBEXFOLDERNAME',title)>0 then do
  55.             say ""
  56.             say "Unable to apply title ("title")"
  57.             say "to the new folder ("outfolder")...."
  58.             exit
  59.          end
  60.       end
  61.    end
  62.    else do
  63.       say ""
  64.       say "Folder ("outfolder") not found."
  65.       say "Please use WebWilly to create it first."
  66.       exit
  67.    end
  68. end
  69. if folder.0=1 then outfolder=folder.1
  70. title=''
  71. rc=SysGetEA(outfolder,'WEBEXFOLDERNAME','title')
  72. if rc>0 | strip(title)='' then do
  73.    say ""
  74.    say outfolder "is not a WebWilly folder."
  75.    exit
  76. end
  77. say ""
  78. say "Adding bookmarks from" indir
  79. say "to" title "folder"
  80. say "(directory" outfolder")...."
  81. say ""
  82. call sysfiletree indir'\*.*','urls','FT'
  83. do i=1 to urls.0
  84.    parse var urls.i y '/' mo '/' d '/' h '/' min size attribs name
  85.    name=strip(name)
  86.    url=linein(name)
  87.    call lineout name
  88.    if wordpos(y,"96 97 98 99")>0 then y="19"||y
  89.    else y="20"||y
  90.    date=y'/'mo'/'d
  91.    if h<12 then noon='am'
  92.    else noon='pm'
  93.    if h>12 then h=h-12
  94.    time=h':'min||noon
  95.    title=''
  96.    rc=SysGetEA(name,'.TYPE','title')
  97.    if rc>0 | (pos('UniformResourceLocator',title)=0 & pos('WebExplorer_Url',title)=0) then do
  98.       say ""
  99.       say "The" name
  100.       say "file does not seem to be a URL object."
  101.       say ""
  102.       iterate
  103.    end
  104.    title=''
  105.    rc=SysGetEA(name,'.SUBJECT','title')
  106.    if rc>0 | title='' then rc=SysGetEA(name,'.LONGNAME','title')
  107.    if rc>0 | title='' then do
  108.       say ""
  109.       say "The" name
  110.       say "file does not seem to be a URL object."
  111.       say ""
  112.       iterate
  113.    end
  114.    title=substr(title,5)
  115.    string='17'x||title||'09'x||url||'09'x||date||'09'x||time||'09'x||'20'x||'09'x||'09'x
  116.    filename=GetPopName(outfolder,'URL')
  117.    if filename='error' then exit
  118.    filename=outfolder'\'filename'.URL'
  119.    call lineout filename
  120.    call lineout filename
  121.    if SysPutEA(filename,'URLFILEBUFFER',string)=0 then say "Created bookmark" filename "for" name
  122.    else say "Error on" name
  123. end
  124. exit
  125. /* Copyright (c)1996 Kari Jackson for InnoVal Systems Solutions, Inc. */
  126. /* Subroutine to produce a *.POP-style filename */
  127. /* Returns 8-character name or "error" */
  128. GetPopName:procedure
  129. parse arg directory,extension
  130. characters='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  131. parse value date("O") with . 2 year "/" month "/" day
  132. parse value time() with hour ":" minute ":" second
  133. month=substr(characters,month+1,1)
  134. day=substr(characters,day+1,1)
  135. hour=substr(characters,hour+1,1)
  136. fifth=minute%36
  137. sixth=substr(characters,minute//36+1,1)
  138. test=second//36
  139. string=year||month||day||hour||fifth||sixth
  140. do j=1 to 36
  141.    test2=(test+j)//36
  142.    if test2=0 then seventh=substr(characters,36,1)
  143.    else seventh=substr(characters,test2,1)
  144.    do i=1 to 36
  145.       tryit=string||seventh||substr(characters,i,1)
  146.       filename=directory||"\"||tryit||'.'||extension
  147.       if stream(filename,'c','query exists')='' then return tryit
  148.    end
  149. end
  150. say ""
  151. say "There have already been 1296 files created in the" directory
  152. say "directory during this minute.  Please wait until the clock"
  153. say "changes and try again."
  154. return 'error'
  155. Syntax:
  156.   say 'Error' rc 'in line' sigl':' errortext(rc)
  157.   say sigl':' sourceline(sigl)
  158.   exit
  159. return
  160. NoREXX:
  161.    say 'Unable to load the REXXUtil functions.  Either the REXXUTIL.DLL file'
  162.    say 'is not on the LIBPATH or REXX support is not installed on this system.'
  163.    exit
  164. return
  165.