Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Скрипт, рандомно выбирающий webm, mp4 и картинки из вашего пака. Должен работать на всех версиях Windows.
- Как использовать:
- 1. Создайте файлы build.vbs и sc.vbs в папке с паком (имена могут быть другими).
- 2. Скопируйте туда соответствующие скрипты (приведены ниже).
- 3. Запустите build.vbs: он обойдет все подкаталоги в вашем паке и выпишет пути ко всем webm, mp4 и картинкам в файл NfJtmmgNyU.txt (имя выбрано такое, чтобы скрипт случайно не перезаписал какой-то из ваших файлов).
- 4. Теперь запускайте sc.vbs: он будет выводить путь к рандомному файлу из вашего пака в диалоговом окне. Постите в тред соответствующий файл. При изменении пака нужно заново проиндексировать его запуском build.vbs.
- ------------------------------------- build.vbs --------------------------------------
- curPath = WScript.ScriptFullname
- curPath = left(curPath, instrrev(curPath, "\"))
- Dim fso1
- Set fso1 = WScript.CreateObject("Scripting.FileSystemObject")
- Dim extensions
- extensions = Array("jpg", "png", "jpeg", "webm", "mp4") ' расширения файлов, которые будет искать скрипт
- Function getList(Path)
- Set oFolders = fso1.GetFolder(Path)
- Set oSubfiles = oFolders.Files
- Set oSubfolders = oFolders.SubFolders
- ResIsEmpty = True
- For Each oFile In oSubfiles
- Dim pth
- pth = oFile.Path
- Dim ok
- ok = False
- For Each ext in extensions
- if right(pth, Len(pth) - InStrRev(pth, ".")) = ext Then
- ok = True
- End If
- Next
- if ok Then
- if ResIsEmpty Then
- ReDim res(0)
- res(0) = pth
- ResIsEmpty = False
- else
- ReDim Preserve res(UBound(res) + 1)
- res(UBound(res)) = pth
- End If
- End If
- Next
- if ResIsEmpty = True Then
- ReDim res(0)
- End If
- For Each oFolder In oSubfolders
- r = getList(oFolder.Path)
- if True Then
- Dim res_len
- res_len = UBound(res) + 1
- ReDim Preserve res(UBound(res) + UBound(r) + 1)
- for i = 0 to UBound(r)
- res(res_len + i) = r(i)
- Next
- End If
- Next
- getList = res
- End Function
- r = getList(curPath)
- For Each x In r
- if x <> "" Then
- strListFolders = strListFolders & x & vbCrLf
- End If
- Next
- outFile= "NfJtmmgNyU.txt"
- Set objFile = fso1.CreateTextFile(outFile, True)
- objFile.Write strListFolders & vbCrLf
- objFile.Close
- ------------------------------------- sc.vbs --------------------------------------
- Dim fso1
- Set fso1 = WScript.CreateObject("Scripting.FileSystemObject")
- strFile = "./NfJtmmgNyU.txt"
- Set objFile = fso1.OpenTextFile(strFile)
- strLine = objFile.ReadLine
- ReDim res(0)
- res(0) = strLine
- Do Until objFile.AtEndOfStream
- strLine = objFile.ReadLine
- ReDim Preserve res(UBound(res) + 1)
- res(UBound(res)) = strLine
- Loop
- objFile.Close
- Randomize
- MsgBox res(Int(Rnd * (UBound(res) + 1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement