Advertisement
jcunews

RandomLine.vbs

Feb 18th, 2019 (edited)
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Periodically get a random line from the source file and save it into the destination file.
  2. 'Double click to run. Terminate the `wscript.exe` to stop script.
  3.  
  4. source = "d:\input\source.txt"
  5. dest = "d:\out folder\dest.txt"
  6.  
  7. set fs = createobject("scripting.filesystemobject")
  8. set src = fs.opentextfile(source)
  9.  
  10. 'if unix file, use `vblf` instead of `vbcrlf`
  11. lines = split(src.readall, vbcrlf)
  12.  
  13. src.close
  14. randomize
  15.  
  16. do
  17.   row = int(rnd * ubound(lines))
  18.   set out = fs.createtextfile(dest, true)
  19.   out.writeline lines(row)
  20.   out.close
  21.  
  22.   'number in milliseconds. 1 second = 1000ms
  23.  wsh.sleep 60 * 1000
  24. loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement