import os
import time
import sys
#
sourc =r'C:\Users\zhuhui\Downloads\新建文件夹'
target_dir=r'D:\app\zhuhui'
print (sourc)
target = target_dir+time.strftime('%Y%m%d%H%M%S')+'.rar'
print(target)
#winrar的安装路径
rar_command = r'"C:\Program Files (x86)\WinRAR\WinRAR.exe" a %s %s -r' % (target,sourc)
if os.system(rar_command) == 0:
print ('Successful backup to', target)
else:
print ('Backup FAILED')