home *** CD-ROM | disk | FTP | other *** search
/ Amiga Times / AmigaTimes.iso / programme / Scalos1.1 / scalos_extras / copy_to_system.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1998-10-06  |  2.9 KB  |  74 lines

  1. /*                              Copy to System
  2. **
  3. **     By : Karol Rybak  (biedron@friko.internet.pl)
  4. **
  5. **
  6. **   This is a simple script that copies system files right to their directories.
  7. **   It's very simple and uninteligent. It just checks file extensions so it won't
  8. **   work with all the system files. I hope you find it usefull.
  9. **
  10. **   USAGE     : copy_to_system.rexx FILENAME
  11. **
  12. **   FILENAME  : filename must be entered in double quotes ("). If you use Scalos
  13. **               it's unimportant but if you want to use this script in some
  14. **               filemanager it's important. But you may change script so that
  15. **               the doubleqoutes won't be required.
  16. */
  17.  
  18.  
  19. /* Some variables to change */
  20.  
  21. classes_dir     =     "System:classes/"
  22. datatypes_dir   =        "System:classes/datatypes/"     /* files with .datatype extension go there */
  23. gadgets_dir     =     "System:classes/gadgets/"
  24. images_dir      =     "System:classes/images/"
  25. devices_dir     =     "System:Devs/"
  26. fonts_dir       =     "System:Fonts/"
  27. libs_dir        =     "System:libs/"
  28. plugins_dir     =     "Scalos:plugins/"
  29. modules_dir     =     "Scalos:modules/"
  30. def_dir         =     "ASK"                       /* unrecognized files go there (you can enter a directory or "ASK" if you want to be asked for a directory to copy a file to)*/
  31.  
  32.                              /* Here we go */
  33.  
  34. Parse arg name                                       /* Get arguments  */
  35.  
  36. font    = FALSE
  37. destdir = def_dir
  38. Do
  39.     If Index(name,'.class')    ~=0   Then Do   ; destdir = classes_dir        ;Leave ;End
  40.     If Index(name,'.datatype') ~=0   Then Do   ; destdir = datatypes_dir      ;Leave ;End
  41.     If Index(name,'.gadget')   ~=0   Then Do   ; destdir = gadgets_dir        ;Leave ;End
  42.     If Index(name,'.image')    ~=0   Then Do   ; destdir = images_dir         ;Leave ;End
  43.     If Index(name,'.device')   ~=0   Then Do   ; destdir = devices_dir        ;Leave ;End
  44.     If Index(name,'.font')     ~=0   Then Do   ; destdir = fonts_dir          ;font=TRUE   ;Leave ;End
  45.     If Index(name,'.library')  ~=0   Then Do   ; destdir = libs_dir           ;Leave ;End
  46.     If Index(name,'.plugin')   ~=0   Then Do   ; destdir = plugins_dir        ;Leave ;End
  47.     If Index(name,'.module')   ~=0   Then Do   ; destdir = modules_dir        ;Leave ;End
  48. End
  49.  
  50. If destdir = "ASK" Then
  51. Do
  52.     addlib('rexxreqtools.library',0,-30)
  53.     destdir=RtFileRequest('System:',,'Select Destination Directory',,'rtfi_flags=freqf_nofiles',)
  54.     If destdir="" Then Exit
  55. End
  56.  
  57. address command 'copy' name destdir
  58.  
  59. If font=TRUE Then                                 /* if a file is a font this will execute (It's getting out a bitmap directory name and copies it to your font directory)*/
  60. Do
  61.     pos=Index(name,'.')
  62.     name=DelStr(name,pos)                          /* This looks a little strange but its working */
  63.     name=name || '"'
  64.     dir=name
  65.     pos=1
  66.     Do Forever
  67.         pos=Index(dir,"/")
  68.         if pos=0 Then break
  69.         dir=Delstr(dir,1,pos)
  70.     End
  71.     address command 'Copy' name '"' || destdir || dir ">NIL:"
  72. End
  73.  
  74.