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 itchat实现微信好友头像拼接图的示例代码
Aug 14 Python
Python实现PS滤镜功能之波浪特效示例
Jan 26 Python
python爬虫基本知识
Mar 05 Python
python实现对csv文件的列的内容读取
Jul 04 Python
python3 json数据格式的转换(dumps/loads的使用、dict to str/str to dict、json字符串/字典的相互转换)
Apr 01 Python
Python将列表中的元素转化为数字并排序的示例
Dec 25 Python
python读取tif图片时保留其16bit的编码格式实例
Jan 13 Python
python自动化unittest yaml使用过程解析
Feb 03 Python
Tensorflow限制CPU个数实例
Feb 06 Python
django2.2 和 PyMySQL版本兼容问题
Feb 17 Python
Python grequests模块使用场景及代码实例
Aug 10 Python
在Windows下安装配置CPU版的PyTorch的方法
Apr 02 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
mysql 全文搜索 技巧
2007/04/27 PHP
php 使用file_get_contents读取大文件的方法
2014/11/13 PHP
PHP框架Laravel学习心得体会
2015/10/28 PHP
YII框架模块化处理操作示例
2019/04/26 PHP
基于jquery用于查询操作的实现代码
2010/05/10 Javascript
JS自动适应的图片弹窗实例
2013/06/29 Javascript
基于JQuery实现的图片自动进行缩放和裁剪处理
2014/01/31 Javascript
jQuery 获取、设置HTML或TEXT内容的两种方法
2014/05/23 Javascript
Javascript中实现trim()函数的两种方法
2015/02/04 Javascript
JavaScript中闭包的写法和作用详解
2016/06/29 Javascript
JavaScript简单验证表单空值及邮箱格式的方法
2017/01/20 Javascript
基于JavaScript实现淘宝商品广告效果
2017/08/10 Javascript
vue watch自动检测数据变化实时渲染的方法
2018/01/16 Javascript
解决vue页面刷新或者后退参数丢失的问题
2018/03/13 Javascript
动态内存分配导致影响Javascript性能的问题
2018/12/18 Javascript
vue过滤器用法实例分析
2019/03/15 Javascript
javascript实现简单打字游戏
2019/10/29 Javascript
js实现带有动画的返回顶部
2020/08/09 Javascript
[00:59]DOTA2英雄背景故事——上古巨神
2020/06/28 DOTA
使用Python实现在Windows下安装Django
2018/10/17 Python
python安装pywin32clipboard的操作方法
2019/01/24 Python
详解Python计算机视觉 图像扭曲(仿射扭曲)
2019/03/27 Python
Python爬虫图片懒加载技术 selenium和PhantomJS解析
2019/09/18 Python
Python 面向对象部分知识点小结
2020/03/09 Python
一个非常简单好用的Python图形界面库(PysimpleGUI)
2020/12/28 Python
VIVOBAREFOOT赤脚鞋:让您的脚做自然的事情
2017/06/01 全球购物
世界上最大的家庭自动化公司:Smarthome
2017/12/20 全球购物
大学生学习生活的自我评价
2013/11/01 职场文书
大学生毕业自我评价范文分享
2013/11/11 职场文书
党校培训思想汇报
2013/12/30 职场文书
毕业证丢失证明范本
2014/09/20 职场文书
群众路线教育实践活动个人对照检查材料
2014/09/22 职场文书
《好妈妈胜过好老师》:每个孩子的优秀都是有源头的
2020/01/03 职场文书
python实现简单区块链结构
2021/04/25 Python
详解JVM系列之内存模型
2021/06/10 Javascript
Nginx流量拷贝ngx_http_mirror_module模块使用方法详解
2022/04/07 Servers