Автор: mozers
Дата сообщения: 21.09.2007 09:53
AlexLev59
Я вполне обхожусь скриптом: [more]DiskDir.vbs
Код: [no]' DiskDir[/no]
[no]' Version: 1.0[/no]
[no]' Autor: mozers™[/no]
[no]' ------------------------------------------------[/no]
[no]' Создает файловые списки в формате DKT (аналогично плагину DiskDir в Total Commander)[/no]
[no]' Пример запуска:[/no]
[no]' cscript DiskDir.vbs "C:\Programm Files" - создает Programm Files.dkt[/no]
[no]' cscript DiskDir.vbs @C:\TEMP\filders.txt MyFavoriteFolders - создает MyFavoriteFolders.dkt, включающий все каталоги, перечисленные в списке filders.txt[/no]
[no]' ------------------------------------------------[/no]
Option Explicit
Dim WshShell, FSO, SciTE
Set WshShell = CreateObject([no]"WScript.Shell"[/no])
Set FSO = CreateObject([no]"Scripting.FileSystemObject"[/no])
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set SciTE = CreateObject([no]"SciTE.Helper"[/no])Dim FSO, WSH
Dim MainFolder
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set WSH = CreateObject([no]"WScript.Shell"[/no])
Set FSO = CreateObject([no]"Scripting.FileSystemObject"[/no])
Set objArgs = WScript.Arguments
If objArgs.Count <> 2 Then
WScript.Echo [no]"DiskDir"[/no]
WScript.Echo [no]"> cscript DiskDir.vbs FolderName|@ListFolderName DiskDirFileName"[/no]
WScript.Quit
End If
out_filename = objArgs(1)
Set out_file = fso.OpenTextFile(out_filename, ForWriting, True)
arg = objArgs(0)
If Left(arg,1)=[no]"@"[/no] Then
arg = Right(arg,Len(arg)-1)
If Not FSO.FileExists(arg) Then
WScript.Echo [no]"Folderlist """[/no] & arg & [no]""" Not Exists!"[/no]
WScript.Quit
End If
WScript.Echo [no]"> Processing..."[/no]
Set list_file = fso.OpenTextFile(arg, ForReading)
Do While Not list_file.AtEndOfStream
MainFolder_path = list_file.ReadLine
DirMainFolder(MainFolder_path)
Loop
list_file.Close
Else
WScript.Echo [no]"> Processing..."[/no]
DirMainFolder(arg)
End If
out_file.Close
WScript.Echo [no]"File """[/no] & out_filename & [no]""" create!"[/no]
WScript.Quit
Sub DirMainFolder(FolderName)
If FSO.FolderExists(FolderName) Then
WScript.Echo FolderName
Set MainFolder = FSO.GetFolder(FolderName)
out_file.WriteLine FolderName & vbTab & [no]"0"[/no] & vbTab & GetDateTime(MainFolder)
DirWithSubFolders MainFolder
End If
End Sub
Sub DirWithSubFolders(ByVal AFolder)
Dim MoreFolders, OneFolder
EnumerateFiles AFolder
Set MoreFolders = AFolder.SubFolders
For Each OneFolder In MoreFolders
folder_path = OneFolder.Path
out_file.WriteLine Right(folder_path, Len(folder_path) - i) & [no]"\"[/no] & vbTab & [no]"0"[/no] & vbTab & GetDateTime(OneFolder)
DirWithSubFolders OneFolder
Next
End Sub
Sub EnumerateFiles(AFolder)
Dim AFile, TheFiles
[no]' On Error Resume Next[/no]
Set TheFiles = AFolder.Files
For Each AFile In TheFiles
out_file.WriteLine AFile.Path & vbTab & AFile.Size & vbTab & GetDateTime(AFile)
Next
End Sub
Function GetDateTime(obj)
date_time = obj.DateLastModified
Set regEx = New RegExp
regEx.Pattern = [no]"[0]?(\d+)[.][0]?(\d+)[.](\d{4})[ ]?[0]?(\d+)[:]?[0]?(\d+)[:]?(\d*)"[/no]
date_time = regEx.Replace(date_time, [no]"$3.$2.$1"[/no] & vbTab & [no]"$4:$5.$6"[/no])
regEx.Pattern = [no]"[0]?(\d+)[.][0]?(\d+)[.](\d{4})"[/no]
GetDateTime = regEx.Replace(date_time, [no]"$3.$2.$1"[/no] & vbTab & [no]"0:0.0"[/no])
End Function