Flasher

|
Posted: Wed Mar 02, 2016 16:30 Post subject: |
|
|
StNff wrote: | нежели список файлов с полными путями | Я же написал, как сделать относительные.
Попросить всегда можно (даже президента).
Code: | '========================================================================
' Создание html-файла с гиперссылками на файлы в структуре активной папки
' Условие: путь запуска - пустой
' Параметры: <фильтр файлов по маске (при необходимости)>
' Пример: *.txt;*.doc;*.docx;*.xls;*.xlsx;*.ppt
'========================================================================
Option Explicit : Dim Filt, L, Shell, FSO, Path, Ln, FName, Text
With WScript.Arguments
If .Count Then Filt = .Item(0) Else Filt = "*.*"
End With : L = vbNewLine
Set Shell = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
Path = FSO.GetAbsolutePathName("") : Ln = Len(Path) + 2 : FFolder Path
FName = FSO.GetFileName(Path) : Path = Path & "\" & FName & ".html"
FSO.CreateTextFile(Path, True, True).Write "<head>" & L & "<br><br>" &_
"<title>" & FName & "</title>" & L & "<style type='text/css'>" & L &_
"body {margin: 40px; background-color:#5D7CBA;font-family:Verdana;" &_
" font-size:16px;}" & L & "h1 {color: #FFD900;font-size:16px;}" & L &_
"hr {color:#FFE3BF;}" & L & "ol {color: #FFD900;}" & L & "a.l {color:" &_
"#F8FAD8; text-decoration: none}" & L & "a:hover.l {text-decoration: " &_
"underline; color:#FFD900}" & "</style>" & L & "</head>" & L & "<body>" &_
L & "<h1 style='text-align: center;'>" & FName & "</h1>" & L & "<hr />" &_
L & "<ol>" & Text & L &"</ol>" & L & "</body>" & L & "</html>"
CreateObject("WScript.Shell").Exec "%COMMANDER_EXE% /O /S /A /L=""" & Path & """"
Sub FFolder(Folder)
Dim Items, F, T : Set Items = Shell.NameSpace(Folder).Items
Items.Filter 73920, Filt
For Each F In Items
T = T & L & "<li><a href="".\" & Mid(F.Path, Ln) & """" & _
"div class='l'>" & vbTab & FSO.GetFileName(F.Path) & "</a><br></li>"
Next : If Items.Count Then _
Text = Text & L & Mid(Folder, Ln) & "<br>" & T & "<br>"
Items.Filter 73888, "*"
For Each F In Items : FFolder F.Path : Next
End Sub |
 Или так:
Code: | '========================================================================
' Создание html-файла с гиперссылками на файлы в структуре активной папки
' Условие: путь запуска - пустой
' Параметры: <фильтр файлов по маске (при необходимости)>
' Пример: *.txt;*.doc;*.docx;*.xls;*.xlsx;*.ppt
'========================================================================
Option Explicit : Dim Filt, L, Shell, FSO, Path, Ln, FName, Text
With WScript.Arguments
If .Count Then Filt = .Item(0) Else Filt = "*.*"
End With : L = vbNewLine
Set Shell = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
Path = FSO.GetAbsolutePathName("") : Ln = Len(Path) + 2 : FFolder Path
FName = FSO.GetFileName(Path) : Path = Path & "\" & FName & ".html"
FSO.CreateTextFile(Path, True, True).Write "<head>" & L & "<title>" &_
FName & "</title>" & L & "<style type='text/css'>" & L & ".l{position:" &_
" absolute; left: 186px;}" & L & "body {margin: 40px; background-color" &_
":#5D7CBA;font-family:MS Reference Sans Serif; font-size:16px;}" & L &_
"h1 {color: #FFD900;font-size:16px;}" & L & "hr {color:#FFE3BF;}" & L &_
"li {list-style-type: none;}" & L & "ol {counter-reset: list1; color:" &_
" #FFD900;}" & L & "ol li:before {counter-increment: list1; content: " &_
"counter(list1) "". "";}" & L & "ol ol { counter-reset: list2;}" & L &_
"ol ol li:before {counter-increment: list2;content: counter(list1) """ &_
"."" counter(list2);}" & L & "a.l {color:#F8FAD8; text-decoration: " &_
"none}" & L & "a:hover.l {text-decoration: underline; color:#FFD900}" &_
"</style>" & L & "</head>" & L & "<body>" & L & "<br><br><h1 style=" &_
L & "'text-align: center;'>" & FName & "</h1>" & L & "<hr />" & L &_
"<ol>" & Text & L &"</ol>" & L & "</body>" & L & "</html>"
CreateObject("WScript.Shell").Exec "%COMMANDER_EXE% /O /S /A /L=""" & Path & """"
Sub FFolder(Folder)
Dim Items, P, F, T
Set Items = Shell.NameSpace(Folder).Items
Items.Filter 73920, Filt
If Folder = Path Then P = ".." Else P = Mid(Folder, Ln)
For Each F In Items
T = T & L & " <li><a href="".\" & Mid(F.Path, Ln) & _
"""div class='l'>" & FSO.GetFileName(F.Path) & "</a></li>"
Next : If Items.Count Then Text = Text & L & " <li>"& P &_
L & " <ol>" & T & L & " </ol>" & L & " </li><br>"
Items.Filter 73888, "*"
For Each F In Items : FFolder F.Path : Next
End Sub |
_________________ Автору сборки TC Image (Andrey_A) настоятельно рекомендуется не распространять на иных ресурсах любую предоставленную мной где-либо техническую информацию по автоматизации и оптимизации в работе с ТС и системой. |
|