Hello
Congratz for the forum, is very organized and helpful.
I have this program, search on folders and subfolders(only 2 levels of folders) and zip files to the zipfile with a similar name.
But because i have files with 50mb and others with 2,5Gb sometimes my program opens more than 1 winzip and i have 2 winzip aplications working in diferents files and the same ZipFile...
bd_lol_backup_20010100001.bak
bd_lol_backup_20010100023.bak
stays in the same zip bad_lol_backup.2001.01.zip!
It is possible my program to know when WinZip finish his task so he can pass to next file?!
Here is my code:
Thank You in advance,
Spocker
Congratz for the forum, is very organized and helpful.
I have this program, search on folders and subfolders(only 2 levels of folders) and zip files to the zipfile with a similar name.
But because i have files with 50mb and others with 2,5Gb sometimes my program opens more than 1 winzip and i have 2 winzip aplications working in diferents files and the same ZipFile...
bd_lol_backup_20010100001.bak
bd_lol_backup_20010100023.bak
stays in the same zip bad_lol_backup.2001.01.zip!
It is possible my program to know when WinZip finish his task so he can pass to next file?!
Here is my code:
Code:
' Declarar Variaveis
' Fazer Ciclo de percorrer pastas
' Verificar se existe o Zip
' Se existe adicionar
' Se não criar e adicionar
Dim folder 'Folder mãe
Dim subFolders 'Folders seguintes
Dim objFSO
Dim zipFileName
folder = "Planning\"
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFolder = objFSO.getFolder(folder)
set subFolders = objFolder.SubFolders
'Ciclo que percorre todas as pastas
For each folderIdx In subFolders
if (StrComp(folderIdx.Name,"report_baby_cliente_budget_backup_20080213")=0) Then 'Exception
Set objFile = folderIdx.Files
For each fileIdx In objFile
If (StrComp(Right(fileIdx.Name,4),".bak")=0) Then
Call CreateNameException(folderIdx.Name, fileIdx.Name)
if (objFSO.FileExists(zipFileName)) Then 'Verificar se o Zip existe
Call ZipIt(folder&"\"&folderIdx.Name&"\"&fileIdx.Name, zipFileName)
else
'criar
Call CreateZip(zipFileName) 'Se não passar daqui é porque
'provavelmente é um problema de permissões
Call ZipIt(folder&"\"&folderIdx.Name&"\"&fileIdx.Name, zipFileName)
End If
WScript.Sleep 20000
End If
Next
else
Set objFile = folderIdx.Files 'Ficheiros de cada pasta
'Ciclo que percorre os ficheiros
For each fileIdx In objFile
If (StrComp(Right(fileIdx.Name,4),".bak")=0) Then
Call CreateName(fileIdx.Name)
if (objFSO.FileExists(zipFileName)) Then 'Verificar se o Zip existe
Call ZipIt(folder&"\"&folderIdx.Name&"\"&fileIdx.Name, zipFileName)
else
'criar
Call CreateZip(zipFileName) 'Se não passar daqui é porque
'provavelmente é um problema de permissões
Call ZipIt(folder&"\"&folderIdx.Name&"\"&fileIdx.Name, zipFileName)
End If
End If
WScript.Sleep 10000
Next
End if
Next
Sub CreateNameException(foldername, nameException)
temp = Len(foldername)+7
fileName = Left(nameException, temp)
fileYear = Mid(nameException, temp+2,4)
fileMonth = Mid(nameException, temp+6,2)
zipFileName = folder&"\"&folderIdx.Name&"\"&fileName&"."&fileYear&"."&fileMonth&".zip"
End Sub
Sub ZipIt(file,zip)
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "winzip32 -m " & zip & " " & file
End Sub
Sub CreateName(name)
temp = InStr(name,"backup")
fileName = Left(name,temp+5)
fileYear = Mid(name,temp+7,4)
fileMonth = Mid(name,temp+11,2)
zipFileName = folder&"\"&folderIdx.Name&"\"&fileName&"."&fileYear&"."&fileMonth&".zip"
End Sub
Sub CreateZip(zipFile)
Call objFSO.CreateTextFile(zipFile, True)
End Sub
Thank You in advance,
Spocker