SHARE
TWEET

MoveTest.VBS

Linda-chan Dec 4th, 2013 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. Dim FSO
  4. Set FSO = CreateObject("Scripting.FileSystemObject")
  5.  
  6. WScript.Echo "Test #1:  " & Now
  7. Test1
  8. WScript.Echo "Test #2:  " & Now
  9. Test2
  10. WScript.Echo "Test #3:  " & Now
  11. Test3
  12. WScript.Echo "All done: " & Now
  13.  
  14. '====================================================================
  15. Private Sub Test1
  16.   Dim Folder
  17.   Dim File
  18.   Dim TargetPath
  19.   Dim Files
  20.   Dim TMP
  21.  
  22.   TargetPath = "Y:\Temp\Test 1 - " & CDbl(Now)
  23.   Set Folder = FSO.GetFolder("\\USURA\TestCore\Test 1")
  24.   If Not FSO.FolderExists(TargetPath) Then FSO.CreateFolder TargetPath
  25.  
  26.   TMP = 0
  27.   ReDim Files(Folder.Files.Count - 1)
  28.  
  29.   For Each File In Folder.Files
  30.     Set Files(TMP) = File
  31.     TMP = TMP + 1
  32.   Next
  33.  
  34.   For Each File In Files
  35.     FSO.MoveFile File.Path, FSO.BuildPath(TargetPath, File.Name)
  36.   Next
  37. End Sub
  38.  
  39. '====================================================================
  40. Private Sub Test2
  41.   Dim Folder
  42.   Dim File
  43.   Dim TargetPath
  44.   Dim Files
  45.   Dim TMP
  46.  
  47.   TargetPath = "Y:\Temp\Test 2 - " & CDbl(Now)
  48.   Set Folder = FSO.GetFolder("\\USURA\TestCore\Test 2")
  49.   If Not FSO.FolderExists(TargetPath) Then FSO.CreateFolder TargetPath
  50.  
  51.   TMP = 0
  52.   ReDim Files(Folder.Files.Count - 1)
  53.  
  54.   For Each File In Folder.Files
  55.     Files(TMP) = File.Path
  56.     TMP = TMP + 1
  57.   Next
  58.  
  59.   For Each File In Files
  60.     FSO.MoveFile File, FSO.BuildPath(TargetPath, FSO.GetFileName(File))
  61.   Next
  62. End Sub
  63.  
  64. '====================================================================
  65. Private Sub Test3
  66.   Dim Folder
  67.   Dim File
  68.   Dim TargetPath
  69.  
  70.   TargetPath = "Y:\Temp\Test 3 - " & CDbl(Now)
  71.   Set Folder = FSO.GetFolder("\\USURA\TestCore\Test 3")
  72.   If Not FSO.FolderExists(TargetPath) Then FSO.CreateFolder TargetPath
  73.  
  74.   For Each File In Folder.Files
  75.     FSO.MoveFile File.Path, FSO.BuildPath(TargetPath, File.Name)
  76.   Next
  77. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top