home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / utilities / propage_pdraw / donsgenies / adproscripts.lha / FileTester.adpro < prev    next >
Encoding:
Text File  |  1995-08-11  |  7.3 KB  |  241 lines

  1. /* Program to use ADPro to check a whole directory of files, including subdirectories. 
  2. A text file listing all dud files found is created.
  3. Each directory is tested twice: in the first pass, each file is simply read; in the second, it is loaded into ADPro to see if it is a valid bitmap. Files with endings such as .info or .pfb which are not used for bitmaps are not checked in this second pass.
  4. If ADPro jams up while trying to load in a binary file which it thinks (wrongly) is a Targa or PCX image, just click on Abort. */
  5.  
  6. /* Written by Don Cox, August 95. Copyright, not Public Domain. */
  7. /* $VER:FileTester.adpro Aug 95 */
  8.  
  9. /* Be careful about tracing this as it can easily fill up Ram: */
  10. /*call open("STDERR","ram:traceFT","W")
  11. trace r*/
  12.  
  13. options results
  14.  
  15. address "ADPro"
  16. ADPRO_TO_FRONT
  17.  
  18. getdir '"Select directory containing files to test"'
  19. if rc=10 then exit
  20. directory = ADPro_Result
  21. if upper(directory) = "RAM DISK:" then directory = "Ram:"
  22.  
  23. getdir '"Select directory for temporary files"' '"ram:"'
  24. if rc=10 then exit
  25. tdirectory = ADPro_Result
  26. if upper(directory) = "RAM DISK:" then directory = "Ram:"
  27. if right(tdirectory,1) ~=":" then tdirectory = tdirectory||"/"
  28.  
  29.  
  30. getfile '"Select file for listing dud files..."'
  31. if rc~=0 then do
  32.     okay1 "No file selected"
  33.     exit
  34.     end
  35. logfile = ADPro_result
  36.  
  37. ILBMonly = 1
  38. OKAYN '"Which files to check"' '"Check bitmaps..."' '"ILBM only|GIF only|All files"'
  39. retc = rc
  40.  
  41. select
  42.     when retc = 0 then ILBMonly = 0
  43.     when retc = 1 then ILBMonly = 1
  44.     when retc = 2 then ILBMonly = 2
  45.     end
  46.  
  47. lformat "UNIVERSAL"
  48. load_type "REPLACE"
  49. filecount = 0
  50. dudfilecount1 = 0
  51. dudfilecount2 = 0
  52.  
  53. /* Check all files in one directory and its descendents */
  54.  
  55. message = "Listing Files ..."
  56. DISPLAYMESSAGE '"'message'"'
  57. call open('dudlogfile',logfile,'W')
  58.  
  59. address command
  60. 'resident c:copy'
  61. 'resident c:delete'
  62. 'list >ram:dirlist 'directory' dirs all LFORMAT="%P%S"'
  63. call open("dirinput","ram:dirlist","r")
  64.  
  65. /* First check pics in root diectory */
  66. 'delete ram:filelist1'
  67. 'delete ram:filelist'
  68. 'list >ram:filelist1 'directory' files LFORMAT="%P%S"'
  69. call open(input,"ram:filelist1","r") /* test in case it's empty */
  70. listtest = readln(input)
  71. call close input
  72.  
  73. if listtest~="" then do
  74.     'sort from ram:filelist1 to ram:filelist'
  75.     address "ADPro"
  76.     call dircheck
  77.     end
  78.  
  79.  
  80. /* Now do all the subdirectories */
  81. do d = 1 to 700
  82.     directory = readln("dirinput")
  83.     if directory = "" then break
  84.     address command
  85.     'delete ram:filelist1'
  86.     'delete ram:filelist'
  87.     'list >ram:filelist1 'directory' files LFORMAT="%P%S"'
  88.     call open(input,"ram:filelist1","r") /* test in case it's empty */
  89.     listtest = readln(input)
  90.     call close input
  91.  
  92.     if listtest~="" then do
  93.         'sort from ram:filelist1 to ram:filelist'
  94.         address "ADPro"
  95.         call dircheck
  96.         end
  97.     end
  98.  
  99. call close('dudlogfile')
  100. address "ADPro"
  101. ADPRO_TO_FRONT
  102. DISPLAYMESSAGE
  103. message = "Done: checked "filecount" files. "dudfilecount1" (pass 1) & "dudfilecount2" (pass2) dud files."
  104. OKAY1 "'"message"'"
  105. exit
  106. end
  107.  
  108. /* ++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */
  109.  
  110.  
  111. getpath:
  112. parse arg allname
  113. pos1 = lastpos("/",allname)
  114. if pos1 = 0 then pos1 = lastpos(":",allname)
  115. filepath = left(allname,pos1)
  116. return filepath
  117.  
  118. getname:
  119. parse arg allname
  120. pos1 = lastpos("/",allname)
  121. if pos1 = 0 then pos1 = lastpos(":",allname)
  122. justname = substr(allname,pos1+1)
  123. return justname 
  124.  
  125. /* +++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ */
  126.  
  127.  
  128. /* Check all the pics in a directory */
  129. dircheck:
  130.  
  131.  
  132. /* first just copy files to Ram: to see if OK */
  133. call open(input,"ram:filelist","r")
  134. address command
  135.  
  136. call writeln('dudlogfile'," ")
  137. logline = "First pass - copy all files in "directory" to temporary directory "
  138. call writeln('dudlogfile',logline)
  139. call writeln('dudlogfile',"++++++++++++++++++")
  140.  
  141. do i = 1 to 7000   /* safety limit of 7000 files  */
  142.     filename = readln(input)
  143.     if filename = "" then break
  144.  
  145.     if filename==logfile then iterate
  146.  
  147.     address 'ADPro'
  148.     message = "First Pass: "filename
  149.     DISPLAYMESSAGE '"'message'"'
  150.     address command
  151.     if word(filename,2) = "files" then iterate /* This line not a file name */
  152.     if word(filename,1) = "TOTAL:" then break  /* or this one */
  153.  
  154.     filecount = filecount+1
  155.     'copy "'filename'" to 'tdirectory'testfile'
  156.     success = rc
  157.     if success~=0 then do
  158.         call writeln('dudlogfile',"'"filename"'")
  159.         dudfilecount1 = dudfilecount1+1
  160.         end
  161.     'delete 'tdirectory'testfile'
  162.  
  163.     end
  164.  
  165. /* Now check if they are valid pictures, loadable by ADPro */
  166. call seek(input,0,"B")
  167. address 'ADPro'
  168. load_type "REPLACE"
  169. lformat "UNIVERSAL"
  170.  
  171. call writeln('dudlogfile'," ")
  172. call writeln('dudlogfile',"++++++++++++++++++")
  173. logline = "Second pass - load bitmap files in "directory" into ADPro "
  174. call writeln('dudlogfile',logline)
  175. call writeln('dudlogfile',"++++++++++++++++++")
  176.  
  177. do i = 1 to 7000   /* safety limit of 7000 files  */
  178.     filename = readln(input)
  179.     if filename = "" then break
  180.     if filename==logfile then iterate
  181.     
  182.     if upper(right(filename,5)) = ".INFO" then iterate
  183.     if upper(right(filename,7)) = ".PSFONT" then iterate
  184.     if upper(right(filename,5)) = ".FONt" then iterate
  185.     if upper(right(filename,7)) = ".PDFONT" then iterate
  186.     if upper(right(filename,4)) = ".PFB" then iterate
  187.     if upper(right(filename,4)) = ".AFM" then iterate
  188.     if upper(right(filename,7)) = ".METRIC" then iterate
  189.     if upper(right(filename,4)) = ".LIB" then iterate
  190.     if upper(right(filename,4)) = ".DEM" then iterate
  191.     if upper(right(filename,4)) = ".DOC" then iterate
  192.     if upper(right(filename,4)) = ".ZIP" then iterate
  193.     if upper(right(filename,4)) = ".LHA" then iterate
  194.     if upper(right(filename,4)) = ".ARC" then iterate
  195.     if upper(right(filename,3)) = ".ME" then iterate
  196.     if upper(right(filename,4)) = ".DAT" then iterate
  197.     if upper(right(filename,3)) = "HLP" then iterate
  198.     if upper(right(filename,4)) = ".ISH" then iterate 
  199.     if upper(right(filename,5)) = ".ICAT" then iterate
  200.     if upper(right(filename,3)) = ".TF" then iterate
  201.     if upper(right(filename,3)) = ".DB" then iterate
  202.     if upper(right(filename,2)) = ".C" then iterate    
  203.     if upper(right(filename,2)) = ".H" then iterate
  204.     if upper(right(filename,3)) = ".GF" then iterate
  205.     if upper(right(filename,5)) = ".PPRX" then iterate
  206.     if upper(right(filename,5)) = ".PDRX" then iterate
  207.     if upper(right(filename,5)) = ".REXX" then iterate
  208.     if upper(right(filename,6)) = ".ADPRO" then iterate
  209.     if upper(right(filename,5)) = ".STEN" then iterate /* Brilliance Stencil file - crashes ADPro */
  210.     if word(filename,2) = "files" then iterate /* This line not a file name */
  211.     if word(filename,1) = "TOTAL:" then break  /* or this one */
  212.  
  213.     message = "Second Pass: "filename
  214.     DISPLAYMESSAGE '"'message'"'
  215.  
  216.     call open("input",filename,"R")
  217.     success = rc
  218.     if success ~= 0 then iterate 
  219.     filetype = right(readch("input",12),4)
  220.     call close("input")
  221.     if (ILBMonly = 1 & filetype ~= "ILBM") then iterate
  222.  
  223.     if (ILBMonly = 2 & upper(right(filename,4)) ~= ".GIF") then iterate 
  224.  
  225.     load '"'filename'"' /* Quotes allow file names with spaces */
  226.     if rc ~=0 then do /* if load fails, log it */
  227.         call writeln('dudlogfile',filename)
  228.         dudfilecount2 = dudfilecount2+1
  229.         message = "Second Pass: "filename" - *** not a valid bitmap ***"
  230.         DISPLAYMESSAGE '"'message'"'
  231.         end
  232.  
  233.     end    /* end of directory */
  234.  
  235. call close(input)
  236.  
  237. ADPRO_UNDISPLAY
  238.  
  239.  
  240. return
  241.