Created
August 30, 2016 02:38
-
-
Save stucka/383836cd013a86e8aa6173b5338f47c3 to your computer and use it in GitHub Desktop.
Find files from one directory tree that aren't in another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
sourcedir = "h:\\D\\video" | |
destdir = "d:\\video" | |
def getfilelist(dirname): | |
filelist = {} | |
count = 0 | |
for root, dirs, files in os.walk(dirname): | |
for file in files: | |
#filelist.append(os.path.join(root, file).replace(dirname + '\\', "")) | |
filelist[file] = os.path.join(root, file).replace(dirname + '\\', '') | |
count += 1 | |
print(str(count)) | |
return filelist | |
sourcefiles = getfilelist(sourcedir) | |
destfiles = getfilelist(destdir) | |
print(str(len(sourcefiles)) + " files found in " + sourcedir) | |
print(str(len(destfiles)) + " files found in " + destdir) | |
for file in sourcefiles: | |
if file not in destfiles: | |
#print(file + " at " + sourcefiles[file]) | |
#print("copy " + sourcedir.replace("\\", "\") + "\\" + sourcefiles[file] + ' d:\\video\\missing\\') | |
print("copy /z \"" + sourcedir + "\\" + sourcefiles[file] + "\" " + "\"" + destdir + "\"") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment