home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / memacs32.zip / filter.cmd < prev    next >
OS/2 REXX Batch file  |  1993-08-07  |  2KB  |  72 lines

  1. ;    FILTER.CMD:    Filter a change through a lot of files
  2. ;            written for MicroEMACS 3.12
  3. ;
  4. ;    This is one incredably usefull command file for filtering changes
  5. ;    in a large collection of files (Like all the MicroEMACS source files)
  6. ;
  7. ;    To use this,
  8. ;
  9. ;    1) modify the marked section to make what changes to the files
  10. ;       you want to happen.
  11. ;    2) start EMACS and type M-X source <ret> filter to start the filter
  12. ;    3) step back. Get a cup of coffee (if there are a lot of files).
  13. ;       Enjoy.
  14.  
  15.     ;Make the file list first
  16.     set %filemask @"What files to be filtered? "
  17.     show-files %filemask
  18.     select-buffer "File List"
  19.     beginning-of-file
  20.     !while &equ $curchar 46
  21.         1 kill-to-end-of-line
  22.     !endwhile
  23.     end-of-file
  24.     set-mark
  25.     previous-line
  26.     kill-region
  27.     write-file "flist"
  28.     unmark-buffer
  29.  
  30.     ;Set up to run through the files
  31.     delete-other-windows
  32.     find-file flist
  33.     beginning-of-file
  34.     select-buffer main
  35.     add-global-mode magic
  36.  
  37.     set %cfile #flist
  38.     !while ¬ &seq %cfile "<END>"
  39.  
  40.         find-file %cfile
  41.         set %b $cbufname
  42.         update-screen
  43.     
  44.         ;**** Here is where to make changes to specify the ****
  45.         ;**** commands to run on each file                 ****
  46.         ;**** Below is an such an example                  ****
  47.         ;query-replace-string is good to use for comfirmations
  48.         ;replace-string lets it all run automatically!!
  49.     
  50.         query-replace-string "3\.[0-9][0-9]" "3.12"
  51.         beginning-of-file
  52.         replace-string "nsearch" "search"
  53.         beginning-of-file
  54.     
  55.         ;Save the Results!
  56.         update-screen
  57.         save-file
  58.     
  59.         ;Dump the already saved buffer
  60.         select-buffer main
  61.         delete-buffer %b
  62.  
  63.         ;on to the next file in the file list
  64.         set %cfile #flist
  65.  
  66.     !endwhile
  67.  
  68. *endit
  69.  
  70.     print "[All Done]~n"
  71.     exit-emacs
  72.