home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / varie / gdtrash1.1rev.2 / arexx / copytodest.dopus5 next >
Text File  |  1999-10-26  |  4KB  |  174 lines

  1. /* By Nils-Erik */
  2. /* Recover the files */
  3. /* Usage in a button :Arexx Dopus5:Arexx/CopyToDest.dopus5 */
  4.  
  5. options results
  6. PARSE ARG portname handle file .
  7. flag=0
  8. IF portname='' THEN portname='DOPUS.1'
  9. ADDRESS VALUE portname
  10.  
  11. If ~Show("P",'trash-handler') then do
  12.     dopus request '"WARNING!!!:"'|| '0a'x ||'" Global Trash is not running!!" OK'
  13.     Exit
  14. End
  15. If ~Show("P",'Trash_lister') then do
  16.     dopus request '"WARNING!!!:"'|| '0a'x ||'" Trash lister not Open!!" OK'
  17.     Exit
  18. End
  19. If ~Show("P",'trash-handler') then do
  20.     dopus request '"WARNING!!!:"'|| '0a'x ||'" Global Trash is not running!!" OK'
  21.     Exit
  22. End
  23.  
  24. if ~show('L', 'rexxtricks.library') then do
  25.   if ~addlib('rexxtricks.library', 0, -30, 0) then do
  26.     dopus request '"rexxtricks.library is not available. Exiting..." OK'
  27.     exit
  28.   end
  29. end
  30.  
  31. if open(1,'Env:trash.prefs','R') then do
  32.     do i=1 to 6
  33.         prefs.i = readln(1)
  34.     end
  35.     if prefs.4 ~="" then trashpath=prefs.4
  36.     Call close(1)
  37. end     
  38. else do
  39.     dopus request '"This Script is a part of "'|| '0a'x ||'"Global Trashcan By Nils-Erik R. Skilnand"'|| '0a'x ||'"and could only be of use with GDTrash installed!!!" OK|Cancel'
  40.     exit    
  41. end
  42. NewPath=Getenv(NewPath)
  43.  
  44. IF handle="" THEN DO
  45.  
  46.  LISTER QUERY SOURCE
  47.  handle=result
  48.  IF RC~=0 THEN DO
  49.   DOPUS REQUEST '"No Source-directory selected !?!" OK!'
  50.   EXIT
  51.  END
  52.  
  53.  LISTER QUERY Handle numselentries
  54.   if result=0 then do
  55.    DOPUS REQUEST '"No files or dirs selected !?!" OK!'
  56.    EXIT
  57.   end
  58. ant=result
  59.  
  60.   LISTER QUERY Handle selfiles stem files.
  61.   LISTER QUERY Handle seldirs stem dirs.
  62.   IF dirs.count~=0 THEN flag=1
  63.  
  64. LISTER SET Handle BUSY ON
  65. LISTER SET Handle newprogress name info bar
  66. lister set handle newprogress title "File Recycler..."
  67. LISTER SET Handle NEWPROGRESS NAME "Recycling Files..."
  68. LISTER SET Handle NEWPROGRESS INFO "Number of files: "ant
  69.  
  70. IF file~="" then DO
  71.  files.0=compress(file,'"')
  72.  files.count=1
  73. END
  74.  
  75. IF file~="" then DO
  76.  dirs.0=compress(file,'"')
  77.  dirs.count=1
  78. END
  79.  
  80. DO i = 0 TO files.count-1
  81.  if newpath==trashpath then do
  82.   Call Open('H',trashpath||files.i||.PATH,'r')
  83.   hp=ReadLn('H')
  84.   if ~exists(hp) then do
  85.    path=hp
  86.    dirpath=''
  87.    do while path~= ''
  88.     parse var path pathdir"/"path
  89.     dirpath=dirpath||pathdir
  90.     address command 'makedir 'dirpath''
  91.     dirpath=dirpath'/'
  92.    end
  93.   end
  94.  
  95.  Address Command 'Move 'trashpath||files.i' to 'hp''
  96.  Call Close('H')
  97.  Address Command 'Delete 'trashpath||files.i||.PATH''
  98.  
  99.  end
  100.  else do
  101.   a=right(newpath,(length(newpath)-(compare(newpath,trashpath)-1)))
  102.   nn=left(a,pos('/',a))
  103.   parse var nn navn'/'
  104.   Call Open('H',trashpath||navn||.PATH,'r')
  105.   hp=ReadLn('H')
  106.   if ~exists(hp) then do
  107.    path=hp
  108.    dirpath=''
  109.    do while path~= ''
  110.     parse var path pathdir"/"path
  111.     dirpath=dirpath||pathdir
  112.     address command 'makedir 'dirpath''
  113.     dirpath=dirpath'/'
  114.    end
  115.   end
  116.  Address Command 'Move 'newpath||files.i' to 'hp''
  117.  Call Close('H')
  118.  end
  119.  lister remove handle files.i
  120. LISTER SET Handle NEWPROGRESS INFO ant "/" ant-i+1
  121. LISTER SET Handle NEWPROGRESS bar ant i+1
  122.  
  123. END
  124.  
  125.  
  126.  
  127. DO i = 0 TO dirs.count-1
  128. if newpath==trashpath then do
  129.  Call Open('H',trashpath||dirs.i||.PATH,'r')
  130.  hp=ReadLn('H')
  131.  if ~exists(hp) then do
  132.   path=hp
  133.   dirpath=''
  134.   do while path~= ''
  135.    parse var path pathdir"/"path
  136.    dirpath=dirpath||pathdir
  137.    address command 'makedir 'dirpath''
  138.    dirpath=dirpath'/'
  139.   end
  140.  end
  141.  
  142.  Address Command 'Move 'trashpath||dirs.i' to 'hp||dirs.i''
  143.  Call Close('H')
  144.  Address Command 'Delete all 'trashpath||dirs.i||.PATH''
  145.  
  146.  end
  147.  else do
  148.   a=right(newpath,(length(newpath)-(compare(newpath,trashpath)-1)))
  149.   nn=left(a,pos('/',a))
  150.   parse var nn navn'/'
  151.   Call Open('H',trashpath||navn||.PATH,'r')
  152.   hp=ReadLn('H')
  153.   if ~exists(hp) then do
  154.    path=hp
  155.    dirpath=''
  156.    do while path~= ''
  157.     parse var path pathdir"/"path
  158.     dirpath=dirpath||pathdir
  159.     address command 'makedir 'dirpath''
  160.     dirpath=dirpath'/'
  161.    end
  162.  end
  163.  Address Command 'Move 'newpath||dirs.i' to 'hp||dirs.i''
  164.  Call Close('H')
  165.  end
  166. lister remove handle dirs.i
  167. LISTER SET Handle NEWPROGRESS INFO ant "/" ant-i+1
  168. LISTER SET Handle NEWPROGRESS bar ant i+1
  169. END
  170. end
  171. lister clear handle progress
  172. LISTER SET Handle BUSY OFF
  173. lister refresh handle
  174.