Creating a .zip archive with Python in MS DOS
Question: I am new to programming. I am trying to learn Python using CH Swaroop's "Byte
of Python". One example is to create a program which will backup some files
from one directory to another and compress them into a .zip format.
Unfortunately the example he gives is only helpful if you happen to be a
linux/unix user. For windows users he says only "Windows users can use the
Info-Zip program" but doesn't elaborate further. This is the code he provides
...

    
    
    #!/usr/bin/python
    # Filename : backup_ver1.py
    
    import os
    import time
    
    
    # 1. The files and directories to be backed up are specified in a list.
    source = [r'C:\Users\ClickityCluck\Documents']
    
    # 2. The backup must be stored in a main backup directory
    target_dir = r'C:\Backup'
    # 3. Zip seems good
    
    # 4. Let's make the name of the file the current date/time
    target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'
    
    # 5. We use the zip command to put the files in a zip archive
    zip_command = "zip -qr '%s' %s" % (target, ''.join(source))
    
    # Run Backup
    if os.system(zip_command) == 0:
        print "Succesful backup to", target
    else:
        print 'BACKUP FAILED :('
    

Can anyone lay out for me a way to do this in the command line on windows 7?
Thank you for your time and I apologize in advance if I have failed to provide
some pertinent information :)


Answer: `zip` is command line utility to create/update/extract ZIP archives, available
on Unix/Linux/Mac OS X. If you want to archive files using a command line
utility, you should find and install an appropriate on (`compress`, for
example, is a part of resource kit).

The another way is to use python's `zipfile` module and make a useful command-
line utility for windows :)

BTW, why your question refers to MS DOS?

