Coding/Python 삽질기2010. 10. 25. 00:25

#-*- coding: cp949 -*-
# 파일 명을 받아서 압축해 주는 스크립트

import os
import sys
import glob
import zipfile


def main(files):
    file_number = len(files)
    target_file = files[1];
        
    target = zipfile.ZipFile(target_file, 'w')
 
    for idx in range (2, file_number):
        all_flist = glob.glob (files[idx])
        for f in all_flist:
            if os.path.isdir(f):
                pass
            target.write(f)
   
    target.close()
  

#-------------------------------------------------------------------------------
# main
if __name__ == "__main__": 
    if len(sys.argv) < 3:
        print "Usage : pyzip source1 [source2]*"
    else:
        main(sys.argv)


'Coding > Python 삽질기' 카테고리의 다른 글

http://www.pythonchallenge.com...Level2  (0) 2010.12.06
1000!  (0) 2010.07.14
Self number ... 2  (0) 2010.07.13
Posted by chobocho