Skip files which haven't changed
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import sys, os, shutil
|
||||
import configparser
|
||||
import sys, os, shutil, filecmp, configparser
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
@@ -95,6 +94,7 @@ fileExtensionsToCopy = (
|
||||
|
||||
totalFiles = 0
|
||||
totalFilesCopied = 0
|
||||
totalFilesAlreadyValid = 0
|
||||
for folder in foldersToCopy:
|
||||
for root, dirs, files in os.walk(sourceDir + "\\" + folder):
|
||||
for file in files:
|
||||
@@ -104,9 +104,15 @@ for folder in foldersToCopy:
|
||||
relname = pathname.replace(sourceDir, "")
|
||||
destpath = copyToDir + relname
|
||||
if os.path.isfile(pathname):
|
||||
|
||||
if os.path.isfile(destpath) and filecmp.cmp(pathname, destpath, shallow=True):
|
||||
print("Skipping " + pathname)
|
||||
totalFilesAlreadyValid = totalFilesAlreadyValid + 1
|
||||
continue
|
||||
|
||||
os.makedirs(os.path.dirname(destpath), exist_ok=True)
|
||||
shutil.copy2(pathname, destpath)
|
||||
totalFilesCopied = totalFilesCopied + 1
|
||||
print(relname)
|
||||
|
||||
print(str(totalFiles) + " total files. " + str(totalFilesCopied) + " copied.")
|
||||
print(str(totalFiles) + " total files. " + str(totalFilesCopied) + " copied. " + str(totalFilesAlreadyValid) + " were not copied because they were identical.")
|
||||
Reference in New Issue
Block a user