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
   |  
'declaration des 2 variables avec la methode arg()
String baseSRC, baseDST
Dim oArgs
 
If wscript.Arguments.length <> 2 Then   
	WScript.Echo "-- Incorrect Number of Arguments --"
	WScript.Quit  
End if
 
Set oArgs=WScript.Arguments ' tableau d'arguments
baseSRC=WScript.Arguments(0) ' premier argument
baseDST=WScript.Arguments(1) ' second argument
 
if not isAFolder(baseSRC) then
	WScript.Echo "-- The " & baseSRC & " folder does NOT exist --"
	WScript.Quit  	
End if
 
 
Dim objXStd
Dim pathZip
pathZip = baseDst & "\myZipFile.zip" 'Nom de l archive
 
'Supprimer l archive si elle existe deja
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(pathZip) then
	objFSO.DeleteFile(pathZip)
end if
set objFSO = nothing
 
'Création de l objet permettant de zipper
set objXStd =  CreateObject("XStandard.Zip") 
 
'take all the textual files
dim path
dim numDossier
numDossier = 1
baseSRC = baseSRC & "\"
do
	Select case (numDossier) 
		case 1 
			path = "rep1\"				
		case 2 
			path = "rep2\"			
	end select 
	'Zipper tout le dossier
	if numDossier = 3 or numDossier = 4 then	
		objXStd.Pack baseSrc & path, pathZip, true		
	else	
		objXStd.Pack baseSrc & path & "*.pdf", pathZip
		objXStd.Pack baseSrc & path & "*.txt", pathZip
		objXStd.Pack baseSrc & path & "*.html", pathZip
'comme je souhaite garder l arborescence, je deplace les fichiers dans mon archive - mettre true dans les param de Pack ne me convient pas
		For Each objItem In objXStd.Contents(pathZip)
			objXStd.Move objItem.Name, path & objItem.Name, pathZip
		Next
	end if
	numDossier = numDossier + 1
loop while (numDossier < 3)
 
'Mettre tous les *.gif et *.jpg de rep1\img dans l archive
	objXStd.Pack baseSrc & "rep1\img\*.gif", pathZip
	objXStd.Pack baseSrc & "rep1\img\*.jpg", pathZip
	path = "rep1\img\"
	For Each objItem In objXStd.Contents(pathZip)
		objXStd.Move objItem.Name, path & objItem.Name, pathZip
	Next
 
 
Set objXStd = Nothing
 
msgbox "End of the zip"
 
WScript.Quit
 
 
Function isAFolder(pathName) Dim isFold
	isFold = false
	Dim fso
	Set fso=wscript.CreateObject("Scripting.FileSystemObject")	
	if fso.FolderExists(pathName) then
		isFold = true
	end if
	isAFolder = isFold
End Function | 
Partager