Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Скрипт, рандомно выбирающий webm, mp4 и картинки из вашего пака. Должен работать на всех версиях Windows.
  2. Как использовать:
  3. 1. Создайте файлы build.vbs и sc.vbs в папке с паком (имена могут быть другими).
  4. 2. Скопируйте туда соответствующие скрипты (приведены ниже).
  5. 3. Запустите build.vbs: он обойдет все подкаталоги в вашем паке и выпишет пути ко всем webm, mp4 и картинкам в файл NfJtmmgNyU.txt (имя выбрано такое, чтобы скрипт случайно не перезаписал какой-то из ваших файлов).
  6. 4. Теперь запускайте sc.vbs: он будет выводить путь к рандомному файлу из вашего пака в диалоговом окне. Постите в тред соответствующий файл. При изменении пака нужно заново проиндексировать его запуском build.vbs.
  7.  
  8.  
  9. ------------------------------------- build.vbs --------------------------------------
  10.  
  11. curPath = WScript.ScriptFullname
  12. curPath = left(curPath, instrrev(curPath, "\"))
  13.  
  14. Dim fso1
  15. Set fso1 = WScript.CreateObject("Scripting.FileSystemObject")
  16.  
  17. Dim extensions
  18. extensions = Array("jpg", "png", "jpeg", "webm", "mp4") ' расширения файлов, которые будет искать скрипт
  19.  
  20. Function getList(Path)
  21.  
  22.     Set oFolders = fso1.GetFolder(Path)
  23.     Set oSubfiles = oFolders.Files
  24.     Set oSubfolders = oFolders.SubFolders
  25.    
  26.     ResIsEmpty = True
  27.    
  28.     For Each oFile In oSubfiles
  29.         Dim pth
  30.         pth = oFile.Path
  31.    
  32.         Dim ok
  33.         ok = False
  34.         For Each ext in extensions
  35.             if right(pth, Len(pth) - InStrRev(pth, ".")) = ext Then
  36.                 ok = True
  37.             End If
  38.         Next
  39.    
  40.         if ok Then
  41.             if ResIsEmpty Then
  42.                 ReDim res(0)
  43.                 res(0) = pth
  44.                 ResIsEmpty = False
  45.             else
  46.                 ReDim Preserve res(UBound(res) + 1)
  47.                 res(UBound(res)) = pth
  48.             End If
  49.         End If
  50.     Next
  51.    
  52.     if ResIsEmpty = True Then
  53.         ReDim res(0)
  54.     End If
  55.    
  56.     For Each oFolder In oSubfolders
  57.         r = getList(oFolder.Path)
  58.        
  59.         if True Then
  60.             Dim res_len
  61.             res_len = UBound(res) + 1
  62.             ReDim Preserve res(UBound(res) + UBound(r) + 1)
  63.            
  64.             for i = 0 to UBound(r)
  65.                 res(res_len + i) = r(i)
  66.             Next
  67.         End If
  68.     Next
  69.    
  70.     getList = res
  71.    
  72. End Function
  73.  
  74. r = getList(curPath)
  75.  
  76. For Each x In r
  77.     if x <> "" Then
  78.         strListFolders = strListFolders & x & vbCrLf
  79.     End If
  80. Next  
  81.  
  82. outFile= "NfJtmmgNyU.txt"
  83. Set objFile = fso1.CreateTextFile(outFile, True)
  84. objFile.Write strListFolders & vbCrLf
  85. objFile.Close
  86.  
  87.  
  88. ------------------------------------- sc.vbs --------------------------------------
  89.  
  90. Dim fso1
  91. Set fso1 = WScript.CreateObject("Scripting.FileSystemObject")
  92.  
  93. strFile = "./NfJtmmgNyU.txt"
  94.  
  95. Set objFile = fso1.OpenTextFile(strFile)
  96. strLine = objFile.ReadLine
  97.  
  98. ReDim res(0)
  99. res(0) = strLine
  100.  
  101. Do Until objFile.AtEndOfStream
  102.     strLine = objFile.ReadLine
  103.     ReDim Preserve res(UBound(res) + 1)
  104.     res(UBound(res)) = strLine
  105. Loop
  106. objFile.Close
  107.  
  108. Randomize
  109. MsgBox res(Int(Rnd * (UBound(res) + 1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement