'==========================================================================
' Выполнение команды с указанием файла-списка, содержащего все файлы,
' заданных расширений, начиная с указанного
'
' Параметры:
' {первый файл файла-списка}
'
' Пример параметров при вызове из TC:
' %P%N
'
' Автор - Batya
'==========================================================================
Option Explicit
'======== Изменяемые параметры ============================================
' Начало команды (до файла-списка)
Const Start = """%ProgramFiles%\IrfanView\i_view32.exe"" /fs /bf /closeslideshow /slideshow="
' Окончание команды
Const Finish = ""
' Файл-список
Const List = "%Temp%\%Random%.txt"
' Удалять ли файл-список после выполнения команды
Const ListDel = True
' Расширения файлов для файла-списка
Dim EXT
Set EXT = CreateObject("Scripting.Dictionary")
EXT.Add "jpg", ""
EXT.Add "bmp", ""
EXT.Add "gif", ""
EXT.Add "jpeg", ""
'==========================================================================
Dim FSO, WSH, Folder, First, F, i, Find, L, Command, Text1, Text2
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSH = CreateObject("WScript.Shell")
Randomize
First = GetPath(WScript.Arguments(0))
Folder = FSO.GetParentFolderName(First)
L = GetPath(Replace(List, "%Random%", CStr(Int(Rnd*10^8)), 1, -1, 1))
Command = GetPath(Start) & """" & L & """" & GetPath(Finish)
Find = False
For Each F In FSO.GetFolder(Folder).Files
If EXT.Exists(LCase(FSO.GetExtensionName(F.Path))) Then
If LCase(First) = LCase(F.Path) Then Find = True
If Find Then
Text1 = Text1 & F.Path & vbNewLine
Else
Text2 = Text2 & F.Path & vbNewLine
End If
End If
Next
FSO.CreateTextFile(L, True).Write Text1 & Text2
WSH.Run Command, 1, ListDel
If ListDel Then FSO.DeleteFile L
Set EXT = Nothing
Set WSH = Nothing
Set FSO = Nothing
WScript.Quit 0
Function GetPath(pPath)
GetPath = WSH.ExpandEnvironmentStrings(pPath)
End Function |