The file structure looks like this:
/email1/spam
/email2/spam
/email3/spam
...
Now, copy all files under all 'spam' directories to a new directory called /email_data/spam
I tried to use shutil.copytree, but it only copy the first directory (copytree requires the destination must not exists).
Then I tried distutils.dir_util.copy_tree, it works, but I don't know why everytime after its copy, there will be some duplicated files. (e.g. spam_email.txt, spam_email_1.txt). There should be 15045 files, but the code copy 16545 which 1500 more...
Finally, I found rsync is very easy to use, as metatoaster said, just use os.system(command).
Actually distutils.dir_util.copy_tree works as well, there is no duplication error of copy, the source directory itself has duplicated files...
How to use python to copy full directory and its contents overwrittenly?