Filtered Sub-Folder to archive.

Nov 28, 2010 at 8:25 PM

Hi All,

I need to filter the Sub-folders that exist within a Parent folder.

Folder Structure of source directory :  SampleDirectory ( has 2 folders as shown below ) 

Green : To be archived.   Red : Not to be archived.

Parent Folder 1 :

           Child Folder 1 - Sample1.txt , Test1.ppt

           Child Folder 2 - Sample2.txt, Test2.ppt

           Child Folder 3 - Sample3.txt, Test3.ppt

           SampleFile1.txt, SampleFile2.ppt

Parent Folder 2 :

           Child Folder 4 - Sample1.txt , Test1.ppt

           Child Folder 5 - Sample2.txt, Test2.ppt

           Child Folder 6 - Sample3.txt, Test3.ppt

           SampleFile3.txt, SampleFile4.ppt

Target Archive Structure :

SampleArchive.zip ( Below are the contents/folder structure within the archive )

Parent Folder 1 :

           Child Folder 1 - Sample1.txt , Test1.ppt

           Child Folder 2 - Sample2.txt, Test2.ppt

           SampleFile1.txt

Parent Folder 2 :

           Child Folder 4 - Sample1.txt , Test1.ppt

           Child Folder 5 - Sample2.txt, Test2.ppt

           SampleFile3.txt

Note : I already have a list of the folder names and files that need to be archived.

I want to maintain the directory structure of the folders that I choose to archive.

For Example :

If i want to zip the above shown directory : SampleDirectory - I need the Archive file to have 2 Parent Folders. These 2 parent folders should have only the Child Folders that I wish to archive.

Others should be neglected and not added to the archive. For the child folders, I want to maintain the directory structure as well.

What I Tried :

             ' Compression. 
             Dim comp As SevenZipCompressor = New SevenZipCompressor()

 

            ' This will take all the Child Folders and add them to the archive. I do preserve the root structure and directory structure.
             ' I get the ParentFolder1 in the archive and all child folders and files in it. But I cannot neglect the ones i dont want.
            comp.CompressDirectory("D:\Harshal\TestData\ParentFolder1\", "D:\Harshal\TestData\CompressedFiles\TestingMultipleFolder.zip", True) 


          '  Using below code , I get the desired folders and the files and folder within them. But I cannot maintain the directory structure.
           ' ChildFolder4 will be directly added to the TestingMultipleFolder.zip, I want it to be added to the ParentFolder2 in the zip file.
           comp.CompressDirectory("D:\Harshal\TestData\ParentFolder2\ChildFolder4", "D:\Harshal\TestData\CompressedFiles\TestingMultipleFolder.zip", True)

           comp.CompressDirectory("D:\Harshal\TestData\ParentFolder2\ChildFolder5", "D:\Harshal\TestData\CompressedFiles\TestingMultipleFolder.zip", True)

Please let me know if you have any suggestions about this.

 

 

Mar 21, 2012 at 12:47 AM

I know this is a very old topic, but wondering if you ever found a solution to this.  This is almost identical to what I am needing to do.  Any info would be appreciated.  Thanks.