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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| Const ForReading = 1, ForWriting = 2, ForAppending = 8 'Parametre pour le zip
'msgbox ShowFolderList(source) 'Boite de dialogue contenat les resultats de la fonction
ShowFolderList(source)
Function ShowFolderList(strSource) 'variable affichant une liste de résultat
Dim fso, Dossiers, fic, fichiers, strListe, f, r
Dim Source, Destination, MyHex, MyBinary, i 'variables por la compression
Dim oApp, oFolder, oCTF, oFile 'variables por la compression
Dim TabNumFic()
source = "D:\test\" 'chemin ou sont les fichiers a zipper
Destination = "D:\save.zip" 'chemin de l'endroit ou va se situer le zip
Dim Zip
'Initialisation des variables pour le tri des fichiers
iDaysOld = 3
Set fso = CreateObject("Scripting.FileSystemObject")
Set Dossiers = fso.GetFolder(Source)
Set fic = Dossiers.Files
numFic = 0
cell = 0
'filtre pour ne recuperer que les fichiers ayant une date de modif > a 3 jours et ayant une extension .log
For Each fichiers In fic
If fichiers.DateLastModified < (Date() - iDaysOld) and Right(fichiers.ShortName,3) = "TXT" then
cell = cell + 1
ReDim Preserve TabNumFic(2, cell)
TabNumFic(1, cell) = numFic
TabNumFic(2, cell) = fichiers.Name
wscript.echo fichiers.Name
end if
numFic = numFic + 1
Next
For i = 1 to ubound(TabNumFic)
'Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim j
Dim oShell
Dim oFileSys
Set shell = CreateObject("WScript.Shell")
WinzipPath=shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\winzip.exe\")
wscript.echo WinzipPath
Source = "D:\test\"
Destination = "D:\" & TabNumFic(2,i) & ".zip"
Set oShell = CreateObject("WScript.Shell")
Set oFileSys = CreateObject("Scripting.FileSystemObject")
ZipName= TabNumFic(2,i)
nomcmd=WinzipPath & " -min -a -r -hs " & ZipName & " " & source & TabNumFic(2,i) & """"
msgbox nomcmd
shell.Run nomcmd, SW_SHOWNORMAL,true
If fso.FileExists(ZipName) Then
set f=fso.GetFile(ZipName)
s="Le fichier """ & f.name & """ de " & f.Size & " octets a été créé" & VBCRLF
s=s & "dans le dossier """ & f.ParentFolder & """" & VBCRLF
wscript.echo s
End If
Set oApp = CreateObject("Shell.Application")
Set oFolder = oApp.NameSpace(Source)
'Set oFile = Nothing
'Set oFileSys = Nothing
'Set FSys = CreateObject("Scripting.FileSystemObject")
'Set MonFic = FSys.GetFile("D:\" & TabNumFic(2,i) & ".zip")
'MonFic.Copy "D:\test\", True
'Set FSys = CreateObject("Scripting.FileSystemObject")
'Set MonFic = FSys.GetFile("D:\" & TabNumFic(2,i) & ".zip")
'monfic.delete
next
Set fso = Nothing
Set Dossiers = Nothing
Set fic = Nothing
Set f = Nothing
End Function |
Partager