pathToZipFile="C:\temp\test.zip"
extractTo="C:\temp\unzip"
set fs = CreateObject("Scripting.FileSystemObject")
set objLog = fs.CreateTextFile("c:\temp\output.log")
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "cmd /c mkdir " & extractTo
Set oShell = Nothing
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.getfolder(extractTo)
For each oFile in folder.Files
oFile.Delete(True)
Next
set sa = CreateObject("Shell.Application")
set ns = sa.NameSpace(pathToZipFile)
set filesInzip = ns.items
sa.NameSpace(extractTo).CopyHere(filesInzip)
EnumCSV extractTo
objLog.Close
sub EnumCSV(targetdir)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.getfolder(targetdir)
For Each File in Folder.Files
If fso.GetExtensionName(File)="csv"Then
ParseCSV(File)
End If
Next
end sub
sub ParseCSV(csv_file)
set fs = CreateObject("Scripting.FileSystemObject")
set objTextFile = fs.OpenTextFile(csv_file)
dim arrStr,lines,lastdate,lasttime
lines=0
Do while NOT objTextFile.AtEndOfStream
arrStr = split(objTextFile.ReadLine,",")
lines=lines+1
Loop
lastdate = Replace(arrStr(0),"""","")
lasttime = Replace(arrStr(1),"""","")
objLog.WriteLine "File: " & csv_file
objLog.WriteLine "Total Lines: " & lines
objLog.WriteLine "Last date: " & lastdate
objLog.WriteLine "Last time: " & lasttime
objLog.WriteLine
objTextFile.Close
end sub
|