home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 3 / CD_Magazyn_EXEC_nr_3.iso / Recent / biz / haage / ArtEffect4Demo.lha / ArtEffect4-Demo / Rexx / procdir.rexx < prev    next >
OS/2 REXX Batch file  |  1998-05-29  |  3KB  |  99 lines

  1. /*
  2.                 Process-Dir.rexx
  3.  
  4.                 Example script that applies a plugin-effect to all files of a
  5.                 directory
  6.  
  7.                 Refer to ArtEffect:Rexx/Rexx.doc for a complete command
  8.                 description
  9.  
  10.                 Attention: filenames must not include any blank spaces!
  11. */
  12.  
  13. OPTIONS RESULTS
  14. OPTIONS FAILAT 21
  15. SIGNAL ON ERROR
  16.  
  17. /* Check for ArtEffect ARexx port */
  18. IF ~SHOW(P,"ArtEffect") THEN DO
  19.         SAY D2C(7)
  20.         SAY "ATTENTION:"
  21.         SAY "Could not find ArtEffect ARexx port."
  22.         SAY "Please make sure that ArtEffect is running."
  23.         SAY
  24.         EXIT
  25. END
  26.  
  27. ADDRESS "ArtEffect"
  28.  
  29. /* check for rexxsupport.library (necessary for ShowDir) */
  30. IF ~SHOW('L', "rexxsupport.library") THEN
  31.         IF ~ADDLIB('rexxsupport.library', 0, -30) THEN DO
  32.                 REQUESTNOTIFY TITLE '"System error"' PROMPT '"rexxsupport.library
  33.                 could not be opened"'
  34.                 EXIT 10
  35.         END
  36.  
  37. /* Filerequester - get a list of all files to be processed */
  38. REQUESTFILE VAR filterdir PATH "ArtEffect:" TITLE '"Choose directory"' DIR
  39. IF ~RC = 0 THEN REQUESTNOTIFY TITLE '"An error has occured"' PROMPT '"You cancelled the requester"'
  40.  
  41. filelist = ShowDir(filterdir, FILE,)
  42.  
  43. REQUESTRESPONSE VAR inplace TITLE '"Please select..."' PROMPT '"Do you want to save the modified pictures|over the original ones?"' OPTIONS "Yes|No"
  44.  
  45. IF inplace = 1 THEN REQUESTFILE VAR savepath TITLE '"Choose directory"' DIR
  46.  
  47. /* keep user from interfering */
  48. LOCKGUI
  49.  
  50. /* repeat loop until all files have been processed */
  51. DO WHILE ~(Compress(filelist) = "")
  52.  
  53.         /* get name of file to be processed */
  54.         currfile = SubWord(filelist, 1, 1)
  55.  
  56.         /* attach full path to filename */
  57.         picpath = filterdir || currfile
  58.  
  59.         /* load the picture */
  60.         LOADPIC picpath
  61.  
  62.         /* change this to the desired plugin */
  63.         DOMETHOD QUIT 'POINTISE'
  64.  
  65.         IF inplace = 0 THEN SAVEPIC NAME picpath PLUGIN 'JFIF-JPEG' /* insert
  66.         desired save format here */
  67.                 ELSE DO
  68.                         picpath = savepath || currfile
  69.                         SAVEPIC NAME picpath PLUGIN 'JFIF-JPEG' /* insert desired save format here */
  70.                 END
  71.  
  72.         /* close the picture */
  73.         CLOSEPIC FORCE
  74.  
  75.         /* remove the file that was just processed from the list of files
  76.         still to be processed */
  77.         filelist = SubStr(filelist, Length(currfile)+2)
  78. END
  79.  
  80. /* Tell the user everything went fine */
  81. REQUESTNOTIFY TITLE '"User information"' PROMPT "All pictures were
  82. processed successfully."
  83.  
  84. /* return control to user - NEVER forget this! */
  85. UNLOCKGUI
  86.  
  87. EXIT
  88.  
  89. /* this function is executed when an error occurs in the script */
  90. ERROR:
  91.         /* tell the user in which line of this script to look for the error */
  92.         REQUESTNOTIFY TITLE '"ARexx-Error"' PROMPT "ARexx-error no." RC " has occured in line" SIGL "."
  93.  
  94.         /* do not forget to unlock the GUI */
  95.         UNLOCKGUI
  96.  
  97. EXIT
  98.  
  99.