Advertisement
Guest User

Randomize files in a folder

a guest
Jul 29th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim num, count, oldName, newName
  2. Dim max,min, strNum
  3. Dim arr
  4. Randomize
  5.  
  6. Set objFSO = CreateObject("Scripting.FileSystemObject")
  7. objStartFolder = "G:\"
  8. Set objFolder = objFSO.GetFolder(objStartFolder)
  9. Set colFiles = objFolder.Files
  10.  
  11. count = objFolder.Files.Count
  12. max = count + 1000
  13. min = 1
  14. For Each objFile in colFiles
  15.     num = GimmeRnd(max, min, strNum)
  16.     'msgbox(num)
  17.    strNum = strNum + Cstr(num) + ","
  18.     oldName = objFile.Name
  19.     newName = Cstr(num) + "_RML_" + oldName
  20.     objFile.Name = newName
  21. Next
  22. msgBox(strNum)
  23. function GimmeRnd(fMax, fMmin, fStrNum)
  24. dim num
  25. num = Int((fMax - fMin + 1) * Rnd + fMin)
  26.     if (inStr(fStrNum, num) > 0) then
  27.        GimmeRnd = GimmeRnd(fMax, fMin, fStrNum)
  28.     else GimmeRnd = num
  29.     end if
  30. end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement