windows系統(tǒng)中python使用rar命令壓縮多個(gè)文件夾示例
#!/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)用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01用Python+OpenCV對(duì)比圖像質(zhì)量的幾種方法
這篇文章主要介紹了用Python+OpenCV對(duì)比圖像質(zhì)量過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-07-07使用Python實(shí)現(xiàn)多功能課堂點(diǎn)名器與抽簽工具
這篇文章主要為大家詳細(xì)介紹了如何使用Python實(shí)現(xiàn)多功能課堂點(diǎn)名器,也可以用作抽簽工具,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-02-02python處理json字符串(使用json.loads而不是eval())
eval 跟json.loads 是不一樣的函數(shù),是有實(shí)現(xiàn)不一樣功能的地方,但是在某些地方它們兩個(gè)函數(shù)的功能是一樣的,本文就詳細(xì)介紹一下2021-09-09python進(jìn)程池實(shí)現(xiàn)的多進(jìn)程文件夾copy器完整示例
這篇文章主要介紹了python進(jìn)程池實(shí)現(xiàn)的多進(jìn)程文件夾copy器,結(jié)合完整實(shí)例形式分析了Python基于多進(jìn)程與進(jìn)程池的文件操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-11-11輕松掌握python設(shè)計(jì)模式之訪問(wèn)者模式
這篇文章主要幫助大家輕松掌握python設(shè)計(jì)模式之訪問(wèn)者模式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11Python+Pygame實(shí)現(xiàn)接小彈珠游戲
這篇文章主要為大家詳細(xì)介紹了Python如何利用Pygame實(shí)現(xiàn)接小彈珠游戲,即用擋板接住會(huì)反彈的小球,隨著次數(shù)的增多,速度變快,分?jǐn)?shù)增多,感興趣的可以了解一下2022-12-12