Batch file to ZIP only files in directory or sub directory
        Posted  
        
            by 
                PaulJavier
            
        on Super User
        
        See other posts from Super User
        
            or by PaulJavier
        
        
        
        Published on 2013-07-23T19:27:52Z
        Indexed on 
            2013/10/31
            22:00 UTC
        
        
        Read the original article
        Hit count: 347
        
I wanted to know if possible how to create a command line to do the following - if a directory exist ZIP only the contents into a ZIP file. If a directory has sub-directories ZIP only the contents into another ZIP file.
Example:
C:\Directory\sample.txt ZIP only sample.txt
C:\Directory\Directory1\sample1.txt ZIP only sample1.txt
C:\Directory\Directory1\Directory2\sample2.txt ZIP only sample2.txt
So it would have created 3 zip files in C:\Directory and sub-directories.
I will not know the name of the sub-directories so can I also assign some sort of variable that says if there are directories or sub-directories in C:\Directory then start above ZIP(s)?
Thank you,
Paul
© Super User or respective owner