Hello,
I am new to python and try to learn more about it. How can I copy or move all the sub-folders (folderA, folderB, folderC,...) from folder1 to folder2 (folder2 is already existed)?
I tried this Click Here for files and it worked. How can I use something similar to this for moving/copying folders?
# move files from one directory to another
# if files alrady exist there, they will be overwritten
# retains original file date/time
import os
import shutil
# make sure that these directories exist
dir_src = "C:\\Python25\\ATest1\\"
dir_dst = "C:\\Python25\\ATest2\\"
for file in os.listdir(dir_src):
print file # testing
src_file = os.path.join(dir_src, file)
dst_file = os.path.join(dir_dst, file)
shutil.move(src_file, dst_file)
Any help is greatly appreciated. Thanks.