home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / tagbet.zip / SCANCD.CMD < prev    next >
OS/2 REXX Batch file  |  1994-06-09  |  5KB  |  134 lines

  1. /*                               SCAN-CD                             */
  2. /*       scans CDs for files.bbs'es copies 'em and creates a         */
  3. /*                   Maximus-Ready Filearea.ctl file                 */
  4. /*                       Author Michael Mrosowski                    */
  5. /*    (fidonet: 2:240/5022.1  internet: lagaffe@offline.sh.sub.de)   */
  6. /* This one is free, change it, delete it, use it, sellit as you want*/
  7.  
  8. /* I don't take any responsability for any trouble or damage the use */
  9. /*                        of this script may cause                   */
  10.  
  11. call RxFuncAdd "SysFileTree", "RexxUtil", "SysFileTree"
  12.  
  13. /*****************Customizeable Area*************************************/
  14. AccessLevel= "Limited"    /*Maximus AccessLevel/Lock*/
  15. FilesBbsName="FILES.BBS"  /*Name of Dir-Files to search for*/
  16. IncludeFileId="N"         /*"Y" includes file_id.diz in *.bbs if present*/
  17. DescStartWord=2           /*Description starts at word 2 (here)         */
  18. BbsDir="C:\MAX\CD"       /*Target Directory for .ctl and the*/
  19.                           /*copied .bbs files*/
  20. DizName="FILE_ID.DIZ"
  21. DoUnzip="@unzip -o "
  22. DoUnarj="@unarj x "
  23. /************************************************************************/
  24.  
  25. IncludeFileId=Substr(Translate(IncludeFileId),1,1)
  26.  
  27. say "This Script will scan a CD for directories with FILES.BBS inside."
  28. say "It will create a Maximus-Ready *.ctl file (include that) and copies"
  29. say "the files.bbs to your a local directory on your harddisk. It will"
  30. say "also include FILE_ID.DIZ descriptions of *.zip and *.arj archives in"
  31. say "the FILES.BBS if desired."
  32. say
  33. say "Current settings:"
  34. say "-----------------"
  35. say "FilesBBS name : "FilesBBSName
  36. say "Include FileId: "IncludeFileId
  37. say "Unzip command : "DoUnzip
  38. say "UnArj command : "DoUnArj
  39. say "Description starts at word no. "DescStartWord
  40. say "Directory where to put the copied files.bbs : "BBSDir
  41. say "AccessLevel for your users to this CD       : "AccessLevel
  42. say
  43. say "Please CHECK the Settings above and correct them if necessary with"
  44. say "a Text-Editor in SCANCD.CMD. The Directory for the FILES.BBS must"
  45. say "already be present (preferrably empty)."
  46. say "Abort at any time with Ctrl+Break (and ENTER if neccessary)."
  47. say "Ehmm.... put now your CD in the drive ;-) and: USE AT YOUR OWN RISK!"
  48. say
  49. say "Your CD drive (e.g. 'F:'): "
  50. pull cddrive
  51.  
  52. currdir=directory(bbsdir)
  53.  
  54. say "Area-Name prefix (max. 4 chars long) :"
  55. pull prebbs
  56.  
  57. areactl=bbsdir"\"prebbs"AREA.CTL"
  58.  
  59. /*trace all*/
  60. say "Here we go. Gathering Directory Data. Please wait some seconds..."
  61. rc=SysFileTree(cddrive"\"filesbbsname,found,"FSO")
  62. if found.0>0 then do
  63.   do i=1 to found.0                 /*Loop for every Files.bbs found*/
  64.     newbbsname=prebbs""i".bbs"      /*write area-infos to *.ctl*/
  65.     dirname=filespec("path",found.i)
  66.     dirname=filespec("name",substr(dirname,1,length(dirname)-1))
  67.     downloaddir=filespec("drive",found.i)filespec("path",found.i)
  68.     rc=lineout(areactl,"Area "prebbs""dirname)
  69.     rc=lineout(areactl,"  FileInfo   "filespec("path",found.i))
  70.     rc=lineout(areactl,"  FileAccess "accesslevel)
  71.     rc=lineout(areactl,"  FileList   "bbsdir"\"newbbsname)
  72.     rc=lineout(areactl,"  Download   "downloaddir)
  73.     rc=lineout(areactl,"End Area")
  74.     rc=lineout(areactl," ")
  75.     say "Processing "found.i
  76.     filefound=0
  77.     do while lines(found.i)>0    /*scan found files.bbs line per line*/
  78.       fbbs=linein(found.i)
  79.       fpath=filespec("drive",found.i)filespec("path",found.i)
  80.       filename=translate(strip(word(fbbs,1)))
  81.       fdesc=subword(fbbs,descstartword,300)
  82.       if pos(".",filename)<>0 then do
  83.         filefound=1
  84.         rc=charout(,filename" ")
  85.         parse value filename with fname "." fext
  86.         diz=0
  87.         if IncludeFileId="Y" then do /* include File_ID.Diz ?? */
  88.           select
  89.             when fext="ZIP" then do
  90.                 DoUnzip""fpath""fname" "dizname" >nul"
  91.                 rc=SysFileTree(dizname,dizfind,"FO")
  92.                 if dizfind.0>0 then
  93.                   diz=1
  94.               end
  95.             when fext="ARJ" then do
  96.                 DoUnarj""fpath""fname" "dizname" >nul"
  97.                 rc=SysFileTree(dizname,dizfind,"FO")
  98.                 if dizfind.0>0 then
  99.                   diz=1
  100.               end
  101.             otherwise
  102.           end
  103.         end
  104.         if diz=1 then do
  105.           do while lines(dizname)>0 /*copy diz-file when found*/
  106.             rc=lineout(newbbsname,left(filename,15)""linein(dizname))
  107.             filename=""
  108.           end
  109.           rc=lineout(dizname)
  110.           "@del "dizname
  111.         end
  112.         else rc=lineout(newbbsname,left(filename,15)""fdesc)
  113.       end
  114.       else do /*not a filename, extended description ?*/
  115.         if filefound=1 then do
  116.           fbbs=strip(fbbs)
  117.           if fbbs<>"" then do
  118.             if substr(fbbs,1,1)="|" then
  119.               fbbs=delstr(fbbs,1,1)
  120.             rc=lineout(newbbsname,left("",15)""fbbs)
  121.           end
  122.           else filefound=0
  123.         end
  124.       end
  125.     end
  126.     rc=lineout(found.i)
  127.     rc=lineout(newbbsname)
  128.   end
  129.   rc=lineout(areactl)
  130.   say "SCANCD finished Ok"
  131. end
  132. else say "No FILES.BBS Files found in Target Directory"
  133. currdir=directory(currdir)
  134.