Ветеран
Сообщения: 27449
Благодарности: 8087
|
Профиль
|
Отправить PM
| Цитировать
Anonymоus, пробуйте (требуется установленный .Net Framework):
читать дальше »
Код: ![Выделить весь код](images/misc/selectcode.png)
Option Explicit
Const WshRunning = 0
Const WshFinished = 1
Const WshFailed = 2
Dim strSourceFolder
Dim arrBlackList
Dim arrWhiteList
Dim objFSO
Dim objWshShell
Dim strContent
Dim strLine
Dim objArrayList
Dim elem
Dim strKey
Dim objRandom
Dim intIndex
strSourceFolder = "D:\Video\MLP"
arrBlackList = Array(".ass", ".srt")
arrWhiteList = Array("Season_1", "Season_2", "Season_3")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strSourceFolder) Then
Set objWshShell = WScript.CreateObject("WScript.Shell")
With objWshShell.Exec("""%comspec%"" /c ""dir /a:-d /b /s """ & strSourceFolder & """""")
If .Status <> WshFailed Then
strContent = ""
Do
strContent = strContent & .StdOut.ReadAll()
Loop Until .Status = WshFinished
End If
End With
With WScript.CreateObject("System.Collections.ArrayList")
For Each strLine In Split(strContent, vbCrLf)
For Each elem In arrWhiteList
If InStr(1, strLine, elem, vbTextCompare) > 0 Then
If Not .Contains(strLine) Then
.Add strLine
End If
End If
Next
Next
For Each strKey In .Clone
For Each elem In arrBlackList
If InStr(1, strKey, elem, vbTextCompare) > 0 Then
.Remove strKey
Exit For
End If
Next
Next
Set objRandom = WScript.CreateObject("System.Random")
Do While .Count > 0
intIndex = objRandom.Next_2(0, .Count)
MsgBox .Item(intIndex)
objWshShell.Run """" & .Item(intIndex) & """", 1, True
.RemoveAt intIndex
Loop
Set objRandom = Nothing
End With
Set objWshShell = Nothing
Else
WScript.Echo "Source folder [" & strSourceFolder & "] not found."
WScript.Quit 1
End If
Set objFSO = Nothing
WScript.Quit 0
|
Отправлено: 05:06, 26-01-2014
| #4
|