windows系统中python使用rar命令压缩多个文件夹示例


Posted in Python onMay 06, 2014
#!/usr/bin/env python
# Filename: backup_ver1.py
import os
import time
# 1. The files and directories to be backed up are specified in a list.
#source=['/home/swaroop/byte','/home/swaroop/bin']
source=['D:\\FileCopier\\*.*','D:\\jeecms_doc\\*.*']
# If you are using Windows, use source=[r'C:\Documents',r'D:\Work'] or something like that
# 2. The backup must be stored in a main backup directory
#target_dir='/mnt/e/backup/' #Remember to change this to what you will be using
target_dir='E:\\temp\\' #Remember to change this to what you will be using
# 3. The files are backed up into a zip file
# 4. The name of the zip archive is the current date and time
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
# 5. We use the zip command (in Unix/Linux) to put the files in a zip archive
#zip_command="zip -qr '%s' %s" %(target,' '.join(source))
zip_command="rar a " + target + ' '.join(source)
# Run the backup
if os.system(zip_command)==0:
 print 'Successful backup to',target
else:
 print 'Backup FAILED'
Python 相关文章推荐
python发布模块的步骤分享
Feb 21 Python
python调用fortran模块
Apr 08 Python
Python 实现一个颜色色值转换的小工具
Dec 06 Python
Python执行时间的计算方法小结
Mar 17 Python
python函数式编程学习之yield表达式形式详解
Mar 25 Python
如何使用Flask-Migrate拓展数据库表结构
Jul 24 Python
Python检查图片是否损坏及图片类型是否正确过程详解
Sep 30 Python
pymysql模块的操作实例
Dec 17 Python
PyCharm中如何直接使用Anaconda已安装的库
May 28 Python
python模块如何查看
Jun 16 Python
python实现批处理文件
Jul 28 Python
详解Python中string模块除去Str还剩下什么
Nov 30 Python
Python中使用动态变量名的方法
May 06 #Python
python完成FizzBuzzWhizz问题(拉勾网面试题)示例
May 05 #Python
使用python实现拉钩网上的FizzBuzzWhizz问题示例
May 05 #Python
python通过scapy获取局域网所有主机mac地址示例
May 04 #Python
python使用内存zipfile对象在内存中打包文件示例
Apr 30 #Python
python数据结构之二叉树的统计与转换实例
Apr 29 #Python
python数据结构之二叉树的遍历实例
Apr 29 #Python
You might like
PHP无限分类(树形类)的深入分析
2013/06/02 PHP
PHP实现简单爬虫的方法
2015/07/29 PHP
PHP实现将base64编码字符串转换成图片示例
2018/06/22 PHP
js分页工具实例
2015/01/28 Javascript
原生js封装二级城市下拉列表的实现代码
2016/06/16 Javascript
jQuery绑定自定义事件的魔法升级版
2016/06/30 Javascript
jQuery联动日历的实例解析
2016/12/02 Javascript
jquery+css实现下拉列表功能
2017/09/03 jQuery
vue2.0与bootstrap3实现列表分页效果
2017/11/28 Javascript
vue中设置、获取、删除cookie的方法
2018/09/21 Javascript
详解js创建对象的几种方法及继承
2019/04/12 Javascript
vue 源码解析之虚拟Dom-render
2019/08/26 Javascript
js实现点击生成随机div
2020/01/16 Javascript
[05:04]DOTA2上海特级锦标赛主赛事第二日TOP10
2016/03/04 DOTA
Python多线程编程简单介绍
2015/04/13 Python
解决Spyder中图片显示太小的问题
2018/04/27 Python
python实现计数排序与桶排序实例代码
2019/03/28 Python
Python 常用模块 re 使用方法详解
2019/06/06 Python
Django发送邮件和itsdangerous模块的配合使用解析
2019/08/10 Python
python文字转语音的实例代码分析
2019/11/12 Python
css3圆角样式分享自定义按钮样式
2013/12/27 HTML / CSS
html5构建触屏网站之touch事件介绍
2013/01/07 HTML / CSS
html5+css3实现一款注册表单实例
2013/04/17 HTML / CSS
StubHub巴西:购买和出售您的门票
2016/07/22 全球购物
Jogun Shop中文官网:韩国知名时尚男装网站
2016/10/12 全球购物
英国体育器材进口商店:UK Sport Imports
2017/03/14 全球购物
幼师自荐信范文
2013/10/06 职场文书
2014乡党委副书记党建工作汇报材料
2014/11/02 职场文书
街道党风廉政建设调研报告
2015/01/01 职场文书
2015年综治维稳工作总结
2015/04/07 职场文书
敬老院义诊活动总结
2015/05/07 职场文书
导游词之河北邯郸
2019/09/12 职场文书
python编写函数注意事项总结
2021/03/29 Python
Python time库的时间时钟处理
2021/05/02 Python
golang 实现时间戳和时间的转化
2021/05/07 Golang
Redis之RedisTemplate配置方式(序列和反序列化)
2022/03/13 Redis