home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Converter / BB_IENG3.LZX / ImageEngineerV3.0 / ARexx / BatchConvert.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-04-18  |  3.0 KB  |  105 lines

  1. /* Image Engineer Script                  */
  2. /* Batch convert and render script        */
  3. /* by Simon Edwards                       */
  4. /*                                        */
  5. /* Demonstrates how to use ARexx to batch */
  6. /* load, render, convert and save images. */
  7.  
  8.  
  9. Options results        /* We want results */
  10. signal on error        /* Setup a place for errors to go */
  11.  
  12. address 'IMAGEENGINEER'
  13. IE_To_Front
  14.  
  15.             /* Get some file names from the user */
  16. 'GET_FILES "Select files to convert" "Ok" "ram:"'
  17. MyFileList=RESULT
  18.  
  19.             /* Ask the user how they want to render */
  20.             /* the images */
  21. 'RENDER_GET COLOUR "Set render options" 0 593920 8 1 256 1 2'
  22. RenderOptions=RESULT
  23.  
  24.             /* Get the desitination directory from the user */
  25. 'GET_DIR "Select Destination Directory" "Ok" "ram:"'
  26. DestDir=result
  27.             /* Fix DestDir so that we can just concatenate the */
  28.             /* file name to it to build complete paths */
  29. endpart=right(DestDir,1)
  30. if endpart~=":" & endpart~="/" then DestDir=DestDir||"/"
  31.  
  32.             /* Get the destination file format */
  33. 'GET_FILE_TYPE "Select Destination File Format"'
  34. FileType=RESULT
  35.  
  36.             /* Let the user enter a file extension to use */
  37. parse var FileType fileext .
  38. 'GET_STRING "Enter file extension" "Ok|Cancel" ".'||fileext||'"'
  39. FileExt=RESULT
  40.             /* Ask the user if they would like this done */
  41.             /* in the Background */
  42. 'REQUEST "Shall I do this in the Foreground or Background?" "Fore|Back"'
  43. Fore=RESULT
  44.  
  45. if Fore~=1 then do    /* If we should work in the background then     */
  46. 'WB_TO_FRONT'        /* we need to bring the WB to the front and     */
  47. 'PRIORITY_SET -1'    /* drop our task priority to something friendly */
  48. end
  49.  
  50.             /* Keep going till we run out of files */
  51. do while MyFileList~=""
  52.             /* Get the next file name */
  53. parse var MyFileList x ';' MyFileList
  54.  
  55.             /* Extract the file name from the complete path */
  56. parse var x ':' temp
  57. if temp="" then temp=x
  58. do forever
  59. parse var temp FileName '/' temp
  60. if temp ="" then break
  61. end
  62.  
  63. 'OPEN "'||x||'" 24'    /* Open the image */
  64. Project=RESULT
  65.  
  66.             /* Set up this images render options */
  67. 'RENDER_SET' Project RenderOptions
  68.  
  69. if Fore=1 then do    /* See if we should be quiet or not when rendering */
  70. 'RENDER' Project
  71. end
  72. else do
  73.             /* We're in the background so we should render */
  74.             /* quietly */
  75. 'RENDER' Project 'QUIET'
  76. end
  77.  
  78.             /* Save the rendered image */
  79. 'SAVE' Project '"'||destdir||filename||fileext||'" "'||filetype||'"'
  80. 'CLOSE' Project
  81. end
  82.  
  83. 'IE_TO_FRONT'
  84. 'PRIORITY_SET 0'
  85. 'REQUEST "All done."'
  86. exit
  87.  
  88. /*******************************************************************/
  89. /* This is where control goes when an error code is returned by IE */
  90. /* It puts up a message saying what happened and on which line     */
  91. /*******************************************************************/
  92. error:
  93. if RC=5 then do            /* Did the user just cancel us? */
  94.     IE_TO_FRONT
  95.     LAST_ERROR
  96.     'REQUEST "'||RESULT||'"'
  97.     exit
  98. end
  99. else do
  100.     IE_TO_FRONT
  101.     LAST_ERROR
  102.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  103.     exit
  104. end
  105.