windows系統(tǒng)中python使用rar命令壓縮多個文件夾示例
#!/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'
相關(guān)文章
pytorch::Dataloader中的迭代器和生成器應(yīng)用詳解
這篇文章主要介紹了pytorch::Dataloader中的迭代器和生成器應(yīng)用詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01用Python+OpenCV對比圖像質(zhì)量的幾種方法
這篇文章主要介紹了用Python+OpenCV對比圖像質(zhì)量過程詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-07-07python處理json字符串(使用json.loads而不是eval())
eval 跟json.loads 是不一樣的函數(shù),是有實現(xiàn)不一樣功能的地方,但是在某些地方它們兩個函數(shù)的功能是一樣的,本文就詳細(xì)介紹一下2021-09-09python進程池實現(xiàn)的多進程文件夾copy器完整示例
這篇文章主要介紹了python進程池實現(xiàn)的多進程文件夾copy器,結(jié)合完整實例形式分析了Python基于多進程與進程池的文件操作相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2019-11-11