home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / mods / psid / nemesids-extras.lzh / Utils / SIDList.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1994-07-13  |  5.8 KB  |  253 lines

  1. /*
  2. ** Usage: SIDList <dir|file> TO <outfile>
  3. **
  4. ** $VER: SIDList.rexx 2.0 (9.7.94)
  5. **
  6. ** NOTE:
  7. **
  8. **    This is Public Domain. That means that you can spread this program
  9. **    as much as you like, but only if nothing is changed and no money
  10. **    are beeing charged.
  11. **    You are not allowed to replicate any portion of the program.
  12. **    Note also that I take no responsibilities for the use of
  13. **    this program considering any damage to or failure of your
  14. **    software, hardware etc.
  15. **
  16. **    Plaese let me know if you like this program by sending me a postcard
  17. **    or something similar to the address below.
  18. **
  19. ** This script extracts Song-info from PlaySID One-Part files in <dir|file>
  20. ** and writes them in plain Database ASCII Delimited format in a specified
  21. ** <outfile>. <dir> will be listed recursive and if <file> is entered, SIDList
  22. ** will list only that particular file.
  23. ** The output data is shown in the following order:
  24. **   "Name","Author","Copyright","Tunes,StartTune","Path"
  25. ** You may change this by changing the two "DBaseLine"'s.
  26. **
  27. ** Example of commandline:
  28. **
  29. **   SHELL>rx SIDList.rexx SID: TO SBData:PlaySIDMusic.lst
  30. **
  31. ** Example of output filelist:
  32. **
  33. **   A)  "Confusion","JCH","1991 Vibrants","1","DATAPAK:SIDMusic/DemoMusic/Vibrants/JCH/Confusion"
  34. **   B)  "Cauldron II","Richard Joseph","1986 Palace","15,8","DATAPAK:SIDMusic/GameMusic/A-C/CauldronII"
  35. **   C)  "Just Died","Banana","1987 T.E.K.","1","DATAPAK:SIDMusic/Ripp Off/Demo-Music/Banana/Just Died"
  36. **
  37. ** Speed:
  38. **   My complete PlaySID Music list is of 1161 Songs, and it took 12.30
  39. **   minutes to extract them all on my A500 with FastRAM and a SCSI II drive.
  40. **
  41. ** My address:
  42. **
  43. **        Ulf Diabelez Harries
  44. **        Åvænget 4, Ellinge
  45. **        5540 Ullerslev
  46. **        Denmark
  47. */
  48.  
  49. OPTIONS RESULTS
  50. SIGNAL ON BREAK_C
  51. SIGNAL ON BREAK_D
  52. SIGNAL ON BREAK_E
  53. SIGNAL ON BREAK_F
  54. SIGNAL ON HALT
  55. SIGNAL ON IOERR
  56. PARSE ARG in_name 'TO' out_name
  57. IF out_name = '' THEN DO
  58.     PARSE ARG in_name 'to' out_name
  59. END
  60. IF out_name = '' THEN DO
  61.     PARSE ARG in_name 'To' out_name
  62. END
  63. IF out_name = '' THEN DO
  64.     PARSE ARG in_name 'tO' out_name
  65. END
  66. IF out_name = '' THEN DO
  67.     CALL InitVar
  68.     CALL PrintTitle
  69.     ECHO Usage
  70.     CALL CleanUp
  71.     EXIT 20
  72. END
  73.  
  74. CALL InitVar
  75. CALL PrintTitle
  76. CALL AddRexxSupport('FAIL')
  77. CALL CheckArgs
  78. CALL ScanDir
  79. CALL PrintInfo
  80. CALL PrintErrors
  81. CALL CleanUp
  82.  
  83. EXIT
  84. /*************************************************************************/
  85. DoFiles:
  86.     perc = 100 / countfiles
  87.     CALL OPEN(t,TempFiles,R)
  88.     DO UNTIL EOF(t)
  89.         Path = READLN(t)
  90.         IF Path = '' THEN DO
  91.             ITERATE
  92.         END
  93.         cperc = TRUNC(cperc+perc,2)
  94.         ECHO UP||UP'* Processing:'EMPTY||BOLD||Path||OFF||CR'* Done:'BOLD cperc||OFF'%'
  95.         CALL PSIDExtract
  96.     END
  97. RETURN
  98.  
  99. PSIDExtract:
  100.     CALL OPEN(f,Path,R)
  101.     IF C2X(READCH(f,8)) ~= '5053494400010076' THEN DO
  102.         ECHO BELL UP
  103.         CALL CLOSE(f)
  104.         CALL OPEN(err,ErrorFile,W)
  105.         CALL WRITELN(err,'"'Path'"')
  106.         RETURN
  107.     END
  108.  
  109.     Playaddress    = READCH(f,6)
  110.     Tunes        = C2D(READCH(f,2))
  111.     StartTune    = C2D(READCH(f,2))
  112.     Speed        = READCH(f,4)
  113.     Name        = STRIP(READCH(f,32),B,NULL)
  114.     Author        = STRIP(READCH(f,32),B,NULL)
  115.     Copyright    = STRIP(READCH(f,30),B,NULL)
  116.     CALL CLOSE(f)
  117.  
  118.     /* Modify this line if you want to change the output */
  119.     DBaseLine  = '"'Name'","'Author'","'Copyright'","'Tunes'","'Path'"'
  120.  
  121.     IF StartTune > 1 THEN DO
  122.         /* If you have modified the "DBaseLine" above, */
  123.         /* you MUST modify this line aswell, so they look alike. */
  124.         /* You may NOT separate "'Songs','SongStart'" from each other */
  125.         DBaseLine = '"'Name'","'Author'","'Copyright'","'Tunes','StartTune'","'Path'"'
  126.     END
  127.  
  128.     CALL WRITELN(d,DBaseLine)
  129.     count = count + 1
  130. RETURN
  131.  
  132. AddRexxSupport:
  133.     SIGNAL ON SYNTAX
  134.     IF ~SHOW('l','rexxsupport.library') THEN
  135.         CALL ADDLIB('rexxsupport.library',0,-30)
  136.         CALL NULL()
  137.         RETURN 1
  138.         Syntax:
  139.             IF ARG(1)='FAIL' THEN DO
  140.             ECHO "Library rexxsupport.library is unavailable."
  141.             EXIT
  142.     END
  143.     ELSE
  144.     SIGNAL OFF SYNTAX
  145.         RETURN 0
  146.  
  147. CheckArgs:
  148.     out_name = STRIP(out_name,B,' "')
  149.     in_name  = STRIP(in_name,B,' "')
  150.  
  151.     IF in_name = '' | in_name = '?' | in_name = '-?' THEN DO
  152.         ECHO Usage
  153.         CALL CleanUp
  154.         EXIT
  155.     END
  156.  
  157.     IF ~EXISTS(in_name) THEN DO
  158.         ECHO BELL'Unable to locate "'in_name'".'CR||CR||Usage
  159.         CALL CleanUp
  160.         EXIT 20
  161.     END
  162.  
  163.     IF ~OPEN(d,out_name,W) THEN DO
  164.         ECHO BELL'Unable to open destination file "'out_name'".'CR||CR||Usage
  165.         CALL CleanUp
  166.         EXIT 20
  167.     END
  168. RETURN
  169.  
  170. ScanDir:
  171.     ECHO '* Scanning:'EMPTY||BOLD in_name OFF||CR
  172.     ADDRESS COMMAND 'LIST FILES ALL "'in_name'" TO' TempFiles 'LFORMAT "%f%n"'
  173.     CALL OPEN(s,TempFiles,R)
  174.     DO UNTIL EOF(s)
  175.         IF READLN(s) = '' THEN DO
  176.             ITERATE
  177.         END
  178.         countfiles = countfiles + 1
  179.     END
  180.     CALL CLOSE(s)
  181.     CALL DoFiles
  182. RETURN
  183.  
  184. PrintErrors:
  185.     CALL CLOSE(err)
  186.     IF ~OPEN(err,ErrorFile,R) THEN DO
  187.         ECHO CR'No errors!'
  188.         RETURN
  189.     END
  190.  
  191.     ECHO CR'Errors:'CR
  192.     DO UNTIL EOF(err)
  193.         error = READLN(err)
  194.         IF error = '' THEN DO
  195.             ITERATE
  196.         END
  197.         ECHO 'File:'BOLD error OFF||CR||'- is not a PlaySID One-Part file!'CR
  198.     END
  199. RETURN
  200.  
  201. InitVar:
  202.     NULL = "00"X
  203.     CR = "0a"X
  204.     BELL = "07"X
  205.     UP = "0b"X
  206.     ESC = "9b"X
  207.     BOLD = ESC"1m"
  208.     OFF = ESC"0m"
  209.     CursorOFF = ESC'302070'X
  210.     CursorON = ESC'2070'X
  211.     EMPTY = ESC'J'
  212.     countfiles = 0
  213.     count = 0
  214.     cperc = 0
  215.     Usage = 'Usage: SIDList <dir|file> TO <outfile>'
  216.     Version = 'V2.0'
  217.     Copyright = 'Copyright ©1994 Ulf Diabelez Harries'
  218.     note = 'SIDList' Version
  219.     info = 'Extracts Song-Info from PlaySID One-Part files'
  220.     ErrorFile = 'T:SIDList.errors'
  221.     TempFiles = 'T:SIDList.files'
  222. RETURN
  223.  
  224. PrintTitle:
  225.     ECHO CursorOFF||CR||BOLD||note||CR||Copyright||CR||info||CR||OFF
  226. RETURN
  227.  
  228. BREAK_C:;BREAK_D:;BREAK_E:;BREAK_F:;HALT:
  229.     ECHO BELL||CR'**BREAK!'
  230.     CALL CleanUp
  231.     EXIT 5
  232. RETURN
  233.  
  234. IOERR:
  235.     ECHO BELL||BELL||BELL||CR'**I/O Error!'
  236.     CALL CleanUp
  237.     EXIT 20
  238. RETURN
  239.  
  240. CleanUp:
  241.     CALL CLOSE(err)
  242.     CALL CLOSE(c)
  243.     CALL CLOSE(d)
  244.     CALL CLOSE(t)
  245.     CALL DELETE(ErrorFile)
  246.     CALL DELETE(TempFiles)
  247.     ECHO CursorON
  248. RETURN
  249.  
  250. PrintInfo:
  251.     ECHO UP||UP'Finished!'EMPTY||CR||'Done:'BOLD 100||OFF'%'EMPTY||CR||CR||'Files processed:' BOLD||countfiles||OFF||CR||'PlaySID files:  ' BOLD||count||OFF
  252. RETURN
  253.