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: он будет выбирать 10 рандомных файлов и копировать их в определенную папку (по умолчанию "C:\randomPics\"). Её необходимо предварительно создать. Число файлов и путь к папке можно изменить, изменив код sc.vbs. Эти параметры задаются в самом начале кода, имеется комментарий. Почитайте файл sc.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 --------------------------------------
- strFile = ".\NfJtmmgNyU.txt"
- Count = 10 ' Число сохраняемых файлов. Можно изменить.
- PathToRandom = "C:\randomPics\" ' Путь, куда файлы копируются. Можно изменить. Осторожно, скрипт стирает все файлы в этой папке в процессе работы.
- Dim fso1
- Set fso1 = WScript.CreateObject("Scripting.FileSystemObject")
- 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
- Set oFolders = fso1.GetFolder(PathToRandom)
- Set oSubfiles = oFolders.Files
- For Each oFile In oSubfiles
- fso1.DeleteFile oFile
- Next
- Randomize
- for i = 1 to Count
- Dim rrr
- rrr = res(Int(Rnd * (UBound(res) + 1)))
- ext = right(rrr, Len(rrr) - InStrRev(rrr, "."))
- fso1.CopyFile rrr, PathToRandom, True
- fileName = PathToRandom & i & "." & ext
- fso1.MoveFile PathToRandom + right(rrr, Len(rrr) - instrrev(rrr, "\")), fileName
- Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement