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

所属分类: 脚本专栏 / python 阅读数: 988
收藏 0 赞 0 分享

复制代码 代码如下:

#!/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 Opencv实现单目标检测的示例代码

这篇文章主要介绍了Python Opencv实现单目标检测的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

Python自动化之UnitTest框架实战记录

这篇文章主要给大家介绍了关于Python自动化之UnitTest框架实战的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

python如何将图片转换素描画

这篇文章主要介绍了python如何将图片转换素描画,帮助大家更好的用python处理图片,感兴趣的朋友可以了解下
收藏 0 赞 0 分享

详解anaconda离线安装pytorchGPU版

这篇文章主要介绍了详解anaconda离线安装pytorchGPU版,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

python计算auc的方法

在本篇文章里小编给大家整理的是关于python计算auc的方法及相关内容,有兴趣的朋友们可以学习下。
收藏 0 赞 0 分享

python speech模块的使用方法

这篇文章主要介绍了python speech模块的使用方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

python之语音识别speech模块

这篇文章主要介绍了python之语音识别speech模块,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

利用Python实现Json序列化库的方法步骤

这篇文章主要给大家介绍了关于利用Python实现Json序列化库的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

python 爬取B站原视频的实例代码

这篇文章主要介绍了python 爬取B站原视频的实例代码,帮助大家更好的理解和使用python 爬虫,感兴趣的朋友可以了解下
收藏 0 赞 0 分享

python开发入门——set的使用

这篇文章主要介绍了python set的使用,帮助大家更好的理解和学习python,感兴趣的朋友可以了解下
收藏 0 赞 0 分享
查看更多