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中通过threading模块定义和调用线程的方法
Jul 12 Python
浅谈python中的__init__、__new__和__call__方法
Jul 18 Python
Python中read()、readline()和readlines()三者间的区别和用法
Jul 30 Python
在python中使用正则表达式查找可嵌套字符串组
Oct 24 Python
利用Tkinter和matplotlib两种方式画饼状图的实例
Nov 06 Python
TensorFlow实现MLP多层感知机模型
Mar 09 Python
python编写弹球游戏的实现代码
Mar 12 Python
django Serializer序列化使用方法详解
Oct 16 Python
python write无法写入文件的解决方法
Jan 23 Python
解决torch.autograd.backward中的参数问题
Jan 07 Python
Python实现视频自动打码的示例代码
Apr 08 Python
python index() 与 rindex() 方法的使用示例详解
Dec 24 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实现仿百度文库,豆丁在线文档效果(word,excel,ppt转flash)
2016/03/10 PHP
浅析PHP中的i++与++i的区别及效率
2016/06/15 PHP
Yii2创建表单(ActiveForm)方法详解
2016/07/23 PHP
PHP实现导出带样式的Excel
2016/08/28 PHP
PHP入门教程之数学运算技巧总结
2016/09/11 PHP
PHP PDO和消息队列的个人理解与应用实例分析
2019/11/25 PHP
JS IE和FF兼容性问题汇总
2009/02/09 Javascript
JS中confirm,alert,prompt函数使用区别分析
2010/04/01 Javascript
jQuery获取样式中颜色值的方法
2015/01/29 Javascript
分析js闭包引起的事件注册问题
2016/03/29 Javascript
关于数据与后端进行交流匹配(点亮星星)
2016/08/03 Javascript
配置nodejs环境的方法
2017/05/13 NodeJs
解决Vue2.0自带浏览器里无法打开的原因(兼容处理)
2017/07/28 Javascript
layer实现关闭弹出层刷新父界面功能详解
2017/11/15 Javascript
微信小程序实现购物车功能
2020/11/18 Javascript
[02:40]DOTA2英雄基础教程 炼金术士
2013/12/23 DOTA
[37:29]完美世界DOTA2联赛PWL S2 LBZS vs Forest 第二场 11.19
2020/11/19 DOTA
linux系统使用python监测系统负载脚本分享
2014/01/15 Python
Python中的Descriptor描述符学习教程
2016/06/02 Python
python生成二维码的实例详解
2017/10/29 Python
matplotlib绘制动画代码示例
2018/01/02 Python
手把手教你用python抢票回家过年(代码简单)
2018/01/21 Python
Python常用特殊方法实例总结
2019/03/22 Python
Python操作Sonqube API获取检测结果并打印过程解析
2019/11/27 Python
Python requests接口测试实现代码
2020/09/08 Python
利用CSS的Sass预处理器(框架)来制作居中效果
2016/03/10 HTML / CSS
洛佩桑酒店官方网站:Lopesan Hotels
2019/04/15 全球购物
关于Java String的一道面试题
2013/09/29 面试题
参观监狱心得体会
2014/01/02 职场文书
汽车队司机先进事迹材料
2014/02/01 职场文书
考研导师推荐信范文
2015/03/27 职场文书
鸦片战争观后感
2015/06/09 职场文书
2019森林防火宣传标语大全!
2019/07/03 职场文书
SpringBoot 集成Redis 过程
2021/06/02 Redis
python和Appium的移动端多设备自动化测试框架
2022/04/26 Python
SpringBoot Http远程调用的方法
2022/08/14 Java/Android