Python指定文件备份工具详解编程语言

file_store_sw_release.py    

#!/usr/bin/python 
 
""" 
2015.07.07 
store all the specified kind of files to the DEST 
Edit by Grey 
""" 
 
import os,re,time,shutil 
 
def FileStore(file_kind,destination_directory): 
    file_list            = [f for f in os.listdir('.') if f.endswith(file_kind)] 
    for file in file_list: 
        time_backup      = time.strftime('%Y_%m_%d',time.localtime(time.time())) 
	new_file_name    = destination_directory + time_backup + file 
	shutil.copy2(file,new_file_name) 
 
FileStore('.hex','E:/sw_release_store/') 
FileStore('.rar','E:/sw_release_store/') 
FileStore('.zip','E:/sw_release_store/') 
print "All the files have been backuped!" 
 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8112.html

(0)
上一篇 2021年7月18日
下一篇 2021年7月18日

相关推荐

发表回复

登录后才能评论