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中的yield函数的用法
Apr 03 Python
Python语言实现百度语音识别API的使用实例
Dec 13 Python
DataFrame 将某列数据转为数组的方法
Apr 13 Python
JupyterNotebook设置Python环境的方法步骤
Dec 03 Python
tensorflow生成多个tfrecord文件实例
Feb 17 Python
Python中使用socks5设置全局代理的方法示例
Apr 15 Python
python实现小程序推送页面收录脚本
Apr 20 Python
Python批量处理csv并保存过程解析
May 16 Python
python名片管理系统开发
Jun 18 Python
Python实现打包成库供别的模块调用
Jul 13 Python
如何用Django处理gzip数据流
Jan 29 Python
Python可变集合和不可变集合的构造方法大全
Dec 06 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 zlib压缩和解压缩swf文件的代码
2008/12/30 PHP
Laravel模板引擎Blade中section的一些标签的区别介绍
2015/02/10 PHP
PHP SPL标准库之数据结构栈(SplStack)介绍
2015/05/12 PHP
PHP正则表达式过滤html标签属性(DEMO)
2016/05/04 PHP
javascript 读取图片文件的大小
2009/06/25 Javascript
jquerydom对象的事件隐藏显示和对象数组示例
2013/12/10 Javascript
理解javascript中的原型和原型链
2015/07/30 Javascript
JavaScript中removeChild 方法开发示例代码
2016/08/15 Javascript
JavaScript实现点击按钮复制指定区域文本(推荐)
2016/11/25 Javascript
基于javascript实现按圆形排列DIV元素(二)
2016/12/02 Javascript
详解用Node.js写一个简单的命令行工具
2018/03/01 Javascript
angularjs使用gulp-uglify压缩后执行报错的解决方法
2018/03/07 Javascript
jQuery实现获取form表单内容及绑定数据到form表单操作分析
2018/07/03 jQuery
在小程序中使用canvas的方法示例
2018/09/17 Javascript
jQuery实现的老虎机跑动效果示例
2018/12/29 jQuery
Node.js原生api搭建web服务器的方法步骤
2019/02/15 Javascript
vue实现登录页面的验证码以及验证过程解析(面向新手)
2019/08/02 Javascript
微信小程序文章详情功能完整实例
2020/06/03 Javascript
Python抓取Discuz!用户名脚本代码
2013/12/30 Python
Python中optionParser模块的使用方法实例教程
2014/08/29 Python
利用python获取某年中每个月的第一天和最后一天
2016/12/15 Python
Python 给某个文件名添加时间戳的方法
2018/10/16 Python
Python实现的插入排序,冒泡排序,快速排序,选择排序算法示例
2019/05/04 Python
python opencv 读取图片 返回图片某像素点的b,g,r值的实现方法
2019/07/03 Python
python自动保存百度盘资源到百度盘中的实例代码
2019/08/26 Python
Python实现获取当前目录下文件名代码详解
2020/03/10 Python
如何使用Python处理HDF格式数据及可视化问题
2020/06/24 Python
纯CSS3实现鼠标滑过按钮动画第二节
2020/07/16 HTML / CSS
医疗保健专业人士购物网站:Scrubs & Beyond
2017/02/08 全球购物
纽约州一群才华横溢的金匠制作而成:Hearth Jewelry
2019/03/22 全球购物
医学类个人求职信范文
2014/02/05 职场文书
纪检干部现实表现材料
2014/08/21 职场文书
2014年度工作总结报告
2014/12/15 职场文书
服务员岗位职责范本
2015/04/09 职场文书
宿舍管理制度范本
2015/08/07 职场文书
污染环境建议书
2015/09/14 职场文书