Python 5 Line code farewell backup painful times

Source: Internet
Author: User
Tags robocopy
Application from demand

I am a photo maniac, even more so since I bought a DSLR! My hard drive is certainly not enough, so every backup is a very painful thing! So think of their own to do a self-help to solve the program automatically, just in learning python, and then use Python call Robocopy wrote an automatic backup of the gadget for their own use, since then farewell to the painful backup ERA! 5 lines of code, at the same time Robocopy replication faster than the copy and paste Windows, greatly saving the backup time;

On the Code
#导入os 模块import os#获取源目录source=raw_input("pls input source documnet:")#获取目标目录des=raw_input ("pls input destination document:")#定义复制命令,robocopy 的命令参数详解, /s 复制子目录,但不复制空的子目录; /copyall 复制所有文件信息;/MON:n:监视源;发现多于 n 个更改时再次运行;/MOT:m:监视源;如果更改,在 m 分钟时间内再次运行。cop=("robocopy %s %s /s /copyall /mot:1 /mon:2 ")%(source,des)#执行robocopy 命令robo=os.system(cop)
Concrete Use effect See:

I have written Python packaged as an. exe file, which can then be used on any platform,

After the first copy is completed, the program will not automatically exit, will always monitor the source folder, if there are two file changes, or 1 minutes of changes, will be the change part of the copy.

Python 5 Line code farewell backup painful times

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.