import os
import os.path
import shutil
import time, datetime
def copyFiles(sourceDir, targetDir):
if sourceDir.find(".svn") > 0:
return
for file in os.listdir(sourceDir):
sourceFile = os.path.join(sourceDir, file)
print sourceFile
targetFile = os.path.join(targetDir, file)
if os.path.isfile(sourceFile):
if not os.path.exists(targetDir):
os.makedirs(targetDir)
if not os.path.exists(targetFile) or (os.path.exists(targetFile) and (os.path.getsize(targetFile) != os.path.getsizie(sourceFile))):
open(targetFile, "wb").write(open(sourceFile,"rb").read())
if os.path.isdir(sourceFile):
First_Directory = False
copyFiles(sourceFile, targetFile)
if __name__ == "__main__":
sourceDir = 'C:\\test_python'
print sourceDir
targetDir = 'C:\\test_python\\test_copy'
print targetDir
copyFiles(sourceDir, targetDir)
import os.path
import shutil
import time, datetime
def copyFiles(sourceDir, targetDir):
if sourceDir.find(".svn") > 0:
return
for file in os.listdir(sourceDir):
sourceFile = os.path.join(sourceDir, file)
print sourceFile
targetFile = os.path.join(targetDir, file)
if os.path.isfile(sourceFile):
if not os.path.exists(targetDir):
os.makedirs(targetDir)
if not os.path.exists(targetFile) or (os.path.exists(targetFile) and (os.path.getsize(targetFile) != os.path.getsizie(sourceFile))):
open(targetFile, "wb").write(open(sourceFile,"rb").read())
if os.path.isdir(sourceFile):
First_Directory = False
copyFiles(sourceFile, targetFile)
if __name__ == "__main__":
sourceDir = 'C:\\test_python'
print sourceDir
targetDir = 'C:\\test_python\\test_copy'
print targetDir
copyFiles(sourceDir, targetDir)