home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / screen / hcf.exe / Basic / Basic_File_101_Copy_Directory_or_Partition.bas < prev    next >
BASIC Source File  |  2003-11-26  |  5KB  |  134 lines

  1. File.TestOnly  = TRUE    ' for run in update mode, Please use FALSE or delete this line
  2. File2.TestOnly = TRUE    ' for run in update mode, Please use FALSE or delete this line
  3.  
  4. copyFrom = "d:"
  5. copyTo   = "g:\\save_D"
  6.  
  7. Image(0).Resample(800,1200)
  8. Image(0).Color = _ColorWhite
  9. line = 1
  10. oldFontSize = Font.Size 
  11. Font.Size = Font.Size * 2
  12. Font.Bold = TRUE
  13. Image(0).Position(10,line*Font.Size).text = "Copy  " + copyFrom + "    to    " + copyTo
  14. Font.Bold = FALSE
  15. line = line + 5
  16. Font.Size = oldFontSize
  17.  
  18. copyFrom = copyFrom + "\\"
  19. copyTo   = copyTo   + "\\"
  20.  
  21. Redraw()
  22. Font.Name = "Courier New"
  23. File.Recursive = TRUE
  24. File.CreateDirectoryByCopyTo = TRUE
  25.  
  26. File.Find( copyTo + "*" )                ' Step 1: Delete all files not in From
  27. For i = 0 To File.NumberOfElements - 1
  28.     f = copyFrom + Mid( File( i ).Path, Len( copyTo ),999)
  29.     File2.Find( f )
  30.     If File2.NumberOfElements = 0 Then
  31.         ret = File(i).Delete()
  32.         If ret <> "" Then
  33.             Image(0).Rectangle(0,line*Font.Size,Image(0).Width,Font.Size).Color = _ColorWhite 
  34.             Image(0).Position(10,line*Font.Size).text = "Delete: " + File(i).Path
  35.             line = line + 1
  36.             Image(0).Position(10,line*Font.Size).text = "        " + ret
  37.             line = line + 1
  38.         Else
  39.             DeleteInTo = DeleteInTo + 1 
  40.         EndIf 
  41.     Else    
  42.         If File(i).Time <> File2(i).Time or File(i).Size <> File2(i).Size Then 
  43.             ret = File(i).Delete()    
  44.             If ret <> "" Then
  45.                 Image(0).Rectangle(0,line*Font.Size,Image(0).Width,Font.Size).Color = _ColorWhite 
  46.                 Image(0).Position(10,line*Font.Size).text = "Delete: " + File(i).Path
  47.                 line = line + 1
  48.                 Image(0).Position(10,line*Font.Size).text = "        " + ret
  49.                 line = line + 1
  50.             Else
  51.                 DeleteTimeOrSizeDifferent = DeleteTimeOrSizeDifferent + 1 
  52.             EndIf 
  53.         EndIf
  54.     EndIf    
  55.     If i Mod 100 = 0 Then
  56.         Image(0).Position(10,line*Font.Size).text = i + " Files proccesed, number of files deleted:  " + DeleteInTo 
  57.         Redraw()
  58.     EndIf    
  59. Next
  60. Beep
  61. Image(0).Rectangle(0,line*Font.Size,Image(0).Width,Font.Size).Color = _ColorWhite 
  62. Image(0).Position(10,line*Font.Size).text = "Number of files deleted:  " + DeleteInTo + " + " + DeleteTimeOrSizeDifferent + " (time/size different)"
  63. line = line + 2
  64. Image(0).Position(10,line*Font.Size).text = "Step 1 finished"
  65. line = line + 3
  66. Redraw()
  67.  
  68. File.SortOrder = _SortDescending
  69. File.OnlyDirectories = TRUE
  70. File2.OnlyDirectories = TRUE
  71. File.Find( copyTo + "*" )                ' Step 2: Delete all directory not in From
  72. For i = 0 To File.NumberOfElements - 1
  73.     f = copyFrom + Mid( File( i ).Path, Len( copyTo ),999)
  74.     File2.Find( f )
  75.     If File2.NumberOfElements = 0 Then
  76.         ret = File(i).Delete()    
  77.         If ret <> "" Then
  78.             Image(0).Rectangle(0,line*Font.Size,Image(0).Width,Font.Size).Color = _ColorWhite 
  79.             Image(0).Position(10,line*Font.Size).text = "Delete Directory: " + File(i).Path
  80.             line = line + 1
  81.             Image(0).Position(10,line*Font.Size).text = "                  " + ret
  82.             line = line + 1
  83.         Else
  84.             DeleteDirctoryInTo = DeleteDirctoryInTo + 1 
  85.         EndIf 
  86.     EndIf    
  87.     If i Mod 10 = 0 Then
  88.         Image(0).Position(10,line*Font.Size).text = i + " Dirctorys proccesed, number of directories deleted:  " + DeleteDirctoryInTo 
  89.         Redraw()
  90.     EndIf    
  91. Next
  92. File.SortOrder = _SortNone
  93. File.OnlyDirectories = FALSE
  94. File2.OnlyDirectories = FALSE
  95. Beep
  96. Image(0).Rectangle(0,line*Font.Size,Image(0).Width,Font.Size).Color = _ColorWhite 
  97. Image(0).Position(10,line*Font.Size).text = "Number of directories deleted: " + DeleteDirctoryInTo
  98. line = line + 2
  99. Image(0).Position(10,line*Font.Size).text = "Step 2 finished"
  100. line = line + 3
  101. Redraw()
  102.  
  103. File.Find( copyFrom + "*" )                ' Step 3: Copy all files not in To
  104. For i = 0 To File.NumberOfElements - 1    '            or Time different
  105.     f = copyTo + Mid( File( i ).Path, Len( copyFrom ),999)
  106.     File2.Find( f )
  107.     If File2.NumberOfElements = 0 Then 
  108.         ret = File(i).CopyTo( f )    
  109.         If ret <> "" Then
  110.             Image(0).Rectangle(0,line*Font.Size,Image(0).Width,Font.Size).Color = _ColorWhite 
  111.             Image(0).Position(10,line*Font.Size).text = "Copy: " + f
  112.             line = line + 1
  113.             Image(0).Position(10,line*Font.Size).text = "      " + ret
  114.             line = line + 1
  115.         Else
  116.             CopyNotInTo = CopyNotInTo + 1 
  117.         EndIf 
  118.     EndIf        
  119.     If i Mod 100 = 0 Then 
  120.         Image(0).Position(10,line*Font.Size).text = "Number of files processed: " + (i+1) + " Number copied: " + CopyNotInTo
  121.         Redraw()
  122.     EndIf    
  123. Next
  124. Image(0).Rectangle(0,line*Font.Size,Image(0).Width,Font.Size).Color = _ColorWhite 
  125. line = line + 1
  126. Image(0).Position(10,line*Font.Size).text = "Number copied: " + CopyNotInTo
  127. line = line + 2
  128. Image(0).Position(10,line*Font.Size).text = "Step 3 finished"
  129. line = line + 3
  130. Image(0).Position(10,line*Font.Size).text = "Number of files processed: " + File.NumberOfFiles
  131. Beep
  132. Sleep(200)
  133. Beep
  134.