Solved

Automatically zip directory ?

Posted on 2001-08-24
24
357 Views
Last Modified: 2007-11-27
HI
I am looking how to zip a directroy and its sub directorys automatically . I have got phzip for dos working well for a file but i also neeed to zip a whole directory automatically.

thanx Craig
0
Comment
Question by:CraigLazar
  • 12
  • 9
  • 2
  • +1
24 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 25 total points
ID: 6424169
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6424228
Optionally, you could get a great funcionality with a free component at
http://www.vbaccelerator.com/codelib/zip/zipvb.htm
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6424254
Hi Guys
Well i need something that is behind the scenes so the usr does not even know i am backing up there directory,
i looked at the links u put up here and it looks like all of them have an interface.

thanx for the quick response

Cheers

Craig
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6424273
No, pal, vbaccelerator hasn't user interface. It is a dll.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6424494
ok sorry about that , i have another look
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6424973
Hi Richie
found it - looks great !!!
but can it zip a directory and all the subfolders and files ?
i had a look at the documentation and all i couls see was backing up a file ????


thanx allot for the help


Craig
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6425396
Yes. It is on documentation. One advise, use only the neccesary code, ( i mean, if you will not use some features, edit .cls files)
This classes have too many callbacks and sometimes VB doen't like it.
Cheers
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6425909
thanx
i will give it a bash
:)
Craig
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6426917
Ups! i meant, .bas files.
Cheers
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6435217
ok thanx Richie
sorry i have not had time to get stuck into it - so i am going to give you the points - is it ok that when i get onto it if i need anyhelp i can ask you ?

cheers

Craig
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6438190
Don't accept my comment until you get a working code.
Yes, you can ask me anytime.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6440404
Hi
ok - if i do not get to it by the end of next week i will answer it (fair ??)

thanx

Craig
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6441153
NO. Just let me know what problem you should get and i should try to solve it.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6444995
thanx Richie
have a good weekend
:)

Craig
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6523358
Hi Richie
Sorry for getting back t this question so late but been overseas on business.

Ihave moved back onto the project i need this for so i will keep in touch with how thigs go

thanx allot
:)

Craig
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6523539
You are welcome (back!)!
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6652717
Hi there Richie
Ok i managed to steel some time and try and get my little app up and running
ok i tried the vb Accelerator sample and it works.
However what i am struggling with is to first loop thru the file catalog i have choosen. ie lets say i want to back up all the files in the following dir c:\prolink\*.*
now there are say 2 sub dirs in this directory, i need to first loop thru all the records in all the sub dirs and compare them to a database list to verify if a file has been changed and needs to be backed up, then i want to copy the file to my backup dir and then run zip utility.

i am just stuck trying to get the app to pick up all subdirs and there file. Say a user adds a new sub directory in there, i need to pcik it up , update the db that there are new files and then copy them to the backup dir

any ideas ?

thanx allot
Craig ?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6652872
Hi Craig, Let me see...
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 6653182
Hi there
ok i have had to change it and comment out the recirse funtion i am trying to build
here is the code that is giving me hassels or i can't get working
    '***************************************************************************************
    'STEP 1 -
    'Loop thru the Current File Catalog and add it to the File Collection
    Set rsFetch = New ADODB.Recordset
    rsFetch.Open "Select * from tblFFList", cn '
    rsFetch.MoveFirst
    Do Until rsFetch.EOF = True
            tmpFiles = rsFetch("Filepath")
            Col_FileList.Add tmpFiles
            rsFetch.MoveNext
    Loop

    '***************************************************************************************
    'STEP 2 -
    'Now call the Function to Search and retrive the Files from the File Catalog
    Set MasterList = FindFiles(Col_FileList, True)
'''''''    Do Until SubDirs.Count = 0
''''''''        MasterList.Add SubDirs
'''''''        tmpFileCol.Add SubDirs
'''''''        Set SubDirs = Nothing
'''''''        Set Col_VerFileList = Nothing
'''''''        Set Col_VerFileList = FindFiles(tmpFileCol, True)
'''''''        MasterList.Add Col_VerFileList
'''''''    Loop


Public Function ParsePath(Path As String) As String
    Dim a
    'Takes a full file specification and returns the path
    For a = Len(Path) To 1 Step -1
        If Mid$(Path, a, 1) = "\" Or Mid$(Path, a, 1) = "/" Then
            'Add the correct path separator for the input
            If Mid$(Path, a, 1) = "\" Then
                ParsePath = LCase$(Left$(Path, a - 1) & "\")
            Else
                ParsePath = LCase$(Left$(Path, a - 1) & "/")
            End If
            Exit Function
        End If
    Next a
End Function
Public Function FindFiles(Files As Collection, ByVal Recurse As Boolean)
On Error GoTo eh:
    Dim attributes, r
    Dim Result As New Collection

    Dim i As Long
    Dim Path
    Dim IsDir As Boolean
    Dim IsFile  As Boolean
    Dim SubDirFound As String
    For i = 1 To Files.Count
        Debug.Print Files(i)
        'Parse the file specification to find the path
        Path = ParsePath(Files(i))
        'Find the files matching the pattern
        r = Dir$(Files(i), 16)
        Do Until r = ""
            'Add the file to the new file list collection
           
            IsDir = IsDirCheck(Path & r)
             If IsDir = True Then
                'Found a subdirectory in the directory path given, so now add this path to the SubDirs collection
                 SubDirFound = (Path & r & "\*.*")
                 SubDirs.Add SubDirFound
                 IsDir = False
            End If
           
            'Verify if it is a file first before adding it to the main collection
            IsFile = IsFileCheck(Path & r)
             If IsFile = True Then
                Result.Add Path & r
            End If
            'Move on to next file, if one exists
            r = Dir$()
        Loop
    Next i
   
    'If the TempFile Collection is not null, then loop thru it
   
   
   
   
    Set FindFiles = Result
eh:
    If Err.Number = -2147217900 Then
        Resume Next
    End If
End Function


Public Function IsDirCheck(ByVal TmpPath As String) As Boolean
    Dim i As Integer
    Dim Container1 As String
    Dim strLen As Integer
    Dim container2 As String
    Dim CounterStr As Integer
   
    strLen = Len(TmpPath)
    For i = 1 To strLen
        Container1 = Right(TmpPath, i)
        Container1 = Left(Container1, 1)
        If Container1 = "\" Or Container1 = "." Then
            If Container1 = "." Then
                'exit it is a file and not a directory
                IsDirCheck = False
                Exit Function
            Else
                 container2 = Right(TmpPath, i)
                 'Found a directory
                 IsDirCheck = True
                 Exit Function
            End If
'                 CounterStr = (strLen - i)
'                If CounterStr = 3 Then
'                    container2 = Right(TmpPath, 3)
'                    MsgBox "file Found "
'                    IsDirCheck = True
                End If
        'End If
    Next i
   IsDirCheck = False

End Function
Public Function IsFileCheck(ByVal TmpPath As String) As Boolean
    Dim i As Integer
    Dim Container1 As String
    Dim strLen As Integer
    Dim container2 As String
    Dim CounterStr As Integer
   
    strLen = Len(TmpPath)
    For i = 1 To strLen
        Container1 = Left(TmpPath, i)
        Container1 = Mid(TmpPath, i, 1)
        If Container1 = "." Then
            CounterStr = (strLen - i)
            If CounterStr = 3 Then
                container2 = Right(TmpPath, 3)
'                MsgBox "file Found "
                IsFileCheck = True
                Exit Function
            End If
        End If
    Next i
   IsFileCheck = False

End Function
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6653710
If i remember well, there is a recursesubdirs property from czip class.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7016975
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20173773.html
http://www.experts-exchange.com/questions/Q.20247869.html
http://www.experts-exchange.com/questions/Q.20253943.html
http://www.experts-exchange.com/questions/Q.20301367.html
http://www.experts-exchange.com/questions/Q.20296324.html
http://www.experts-exchange.com/questions/Q.20296326.html

To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20270469.html

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7021759
Hi
sorry i have left this question open

to the moderators , how can i split these points to everyone who has helped
unfortunately i have been moved of the project again, it has been put on the back shelf.

Sorry Again

craig
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 7021760
Hi
sorry i have left this question open

to the moderators , how can i split these points to everyone who has helped
unfortunately i have been moved of the project again, it has been put on the back shelf.

Sorry Again

craig
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7022027
Thanks, Craig.  I have processed this point split for you.  Half awarded in this question, the other half here:

Points for Richie_Simonetti -> http://www.experts-exchange.com/jsp/qShow.jsp?qid=20302624

Moondancer - EE Moderator
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now