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实现爬取需要登录的网站完整示例
Aug 19 Python
python数据类型判断type与isinstance的区别实例解析
Oct 31 Python
python做量化投资系列之比特币初始配置
Jan 23 Python
使用python装饰器计算函数运行时间的实例
Apr 21 Python
Python3匿名函数用法示例
Jul 25 Python
Django models.py应用实现过程详解
Jul 29 Python
Python Pickle 实现在同一个文件中序列化多个对象
Dec 30 Python
Python sep参数使用方法详解
Feb 12 Python
Python文本文件的合并操作方法代码实例
Mar 31 Python
keras 获取某层输出 获取复用层的多次输出实例
May 23 Python
Pytorch实验常用代码段汇总
Nov 19 Python
Python页面加载的等待方式总结
Feb 28 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
二次元帅气男生排行榜,只想悄悄收藏系列
2020/03/04 日漫
用缓存实现静态页面的测试
2006/12/06 PHP
PHP mysql与mysqli事务使用说明 分享
2013/08/17 PHP
PHP伪造来源HTTP_REFERER的方法实例详解
2015/07/06 PHP
PHP使用mongoclient简单操作mongodb数据库示例
2019/02/08 PHP
Jquery 数据选择插件Pickerbox使用介绍
2012/08/24 Javascript
JQuery中serialize()用法实例分析
2015/02/06 Javascript
jQuery替换textarea中换行的方法
2015/06/10 Javascript
Vue.js实现简单ToDoList 前期准备(一)
2016/12/01 Javascript
jQuery实现的简单悬浮层功能完整实例
2017/01/23 Javascript
Angular.js 4.x中表单Template-Driven Forms详解
2017/04/25 Javascript
对象不支持indexOf属性或方法的解决方法(必看)
2017/05/28 Javascript
Javascript Promise用法详解
2018/05/10 Javascript
从零开始搭建vue移动端项目到上线的步骤
2018/10/15 Javascript
非常实用的jQuery代码段集锦【检测浏览器、滚动、复制、淡入淡出等】
2019/08/08 jQuery
Python pass 语句使用示例
2014/03/11 Python
python3 遍历删除特定后缀名文件的方法
2018/04/23 Python
python线程池threadpool使用篇
2018/04/27 Python
Python中的CSV文件使用"with"语句的方式详解
2018/10/16 Python
Python 实现子类获取父类的类成员方法
2019/01/11 Python
python+logging+yaml实现日志分割
2019/07/22 Python
python使用minimax算法实现五子棋
2019/07/29 Python
python中rb含义理解
2020/06/18 Python
如何解决python多种版本冲突问题
2020/10/13 Python
matplotlib绘制多子图共享鼠标光标的方法示例
2021/01/08 Python
一个不错的HTML5 Canvas多层点击事件监听实例
2014/04/29 HTML / CSS
施华洛世奇澳大利亚官网:SWAROVSKI澳大利亚
2017/01/06 全球购物
英国定做窗帘和纺织品面料一站式商店:Dekoria
2018/08/29 全球购物
linux面试相关问题
2013/04/28 面试题
国际经济贸易专业推荐信
2013/11/06 职场文书
中班开学寄语
2014/04/04 职场文书
张家口市高新区党工委群众路线教育实践活动整改方案
2014/10/25 职场文书
导游词之西安骊山
2019/12/20 职场文书
《风不能把阳光打败》读后感3篇
2020/01/06 职场文书
MySQL中varchar和char类型的区别
2021/11/17 MySQL
多线程Spring通过@Scheduled实现定时任务
2022/05/25 Java/Android