1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| 'Pour récupérer l'heure d'ouverture de la session notée dans le fichier logsession.txt
Const ForReading = 1
Dim oFso, log
Set oFso = CreateObject("Scripting.FileSystemObject")
Set log = oFso.OpenTextFile("C:\Documents and Settings\All Users\Documents\logsession.txt", ForReading)
Do While log.AtEndOfStream <> True
r = log.ReadLine
loop
log.close
ligne=r
Dim st
st="ligne"
vraieheure=Mid(ligne,22,2)
vraieminute=Mid(ligne,25,2)
vraieseconde=Mid(ligne,28,2)
heurelogon=(Timeserial(vraieheure,vraieminute,vraieseconde))
'wscript.echo heurelogon
'Pour récupérer la date d'aujourd'hui au format dd.mm.yyyy
Function Pad2(Str)
If Len(Str) = 1 Then
Pad2 = "0" & Str
Else
Pad2 = Str
End If
End Function
Function Datelogon(vsDate)
Datelogon = Pad2(Right(Day(vsDate), 2)) & "." & Pad2(Month(vsDate)) & "." & Pad2(Year(vsDate))
End Function
daylogon = Datelogon(Now)
'wscript.echo daylogon
'Pour compter récursivement les fichiers
Sub RechercheImg (objFolder) ' La fonction prend en paramètre un objet Dossier
For Each objSubFolder In objFolder.SubFolders
RechercheImg(objSubFolder) ' Pour chaque sous-dossier, on rappelle la fonction récursive
Next
nbJpg = 0
nbTif = 0
For Each objFile In objFolder.Files
'Pour vérifier que les fichiers soit d'aujourd'hui
f3 = objFile.DateLastModified
toto = DateDiff ("d", daylogon, f3)
titi = DateDiff ("s", heurelogon, f3)
'wscript.echo f3
'wscript.echo toto
'wscript.echo titi
'Pour compter tif et jpg d'aujourd'hui
If Lcase(Right(objFile.Name, 4)) = ".jpg" and toto = 0 and titi >= 0 Then
nbJpg = nbJpg + 1
ElseIf Lcase(Right(objFile.Name, 4)) = ".tif" and toto = 0 and titi >= 0 Then
nbTif = nbTif + 1
End If
next
Set Fso = CreateObject("Scripting.FileSystemObject")
Set f = Fso.OpenTextFile("C:\Documents and Settings\All Users\Documents\rapport.txt", 8)
f.Write (nbJpg & " jpg et " & nbTif & " tif" & vbnewline)
End Sub
'Dossier de base pour la récursivité, exemple : C:
Set objFso = CreateObject("Scripting.FileSystemObject")
strFolderBase = "C:\Documents and Settings\All Users\Documents"
If NOT objFso.FolderExists(strFolderBase) Then WScript.Quit 1 'Juste pour vérification, même si dans cet exemple c'est inutile
Set objFolderBase = objFso.GetFolder(strFolderBase)
RechercheImg (objFolderBase) |
Partager