Color Scheme
搜索用户
帐号
密码
注册
old site http://222.195.74.11/
English Version 当前位置: 首页 >> 郭帆 : 个人简历 - 发表论文 - 博客

脚本

Poster:

1. my first script
used for backup files

#!/D:python
# Filename: backup/py

import os
import time
# 1. The files and directories to be backed up are specified in a list.
source = [r'D:studystudy ',r'D:mine ', r'D:documentbackup ' ]
# 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 = r'D:/Downloads/'  # 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') + '.rar'       #%Y%m%d%H%M%S

# 5. We use the zip command (in Unix/Linux) to put the files in a zip archive
zip_command = "Rar a -r %s %s" % (target, ''.join(source))

# Run the backup
if os.system(zip_command) == 0:
   print 'Successful backup to', target
else:
   print 'Backup FAILED'
郭帆
Posted at 2006-12-31 10:45 CST
Last modified at 2006-12-31 10:45 CST
Link to this poster
Source Code
Top


位置 | 访问统计 | FAQ
Best view under the 1024x768 resolution and with the normal size of fonts.
Designed & developed by Yuming Wang, run for 6364 days since December 15, 2006, and last upgraded on May 28th, 2009.
Powered by Apache + PHP coded cOpfOs 3.11.1 last upgraded on February 22nd, 2010.
Copyright © 2006, all rights reserved.