I am a very new newbee.
I have a a hard drive full of possible duplicate backup files that need to be moved to an original location. If while moving the files an existing file on destination, the source file will be deleted, thus not taking time to overwrite on the destination. Especially useful when moving 5GB and larger files to the destination.
import filecmp
import shutil
source_file = “E:/PyTest/Pictures – Original”
destination_file = “E:/PyTest/Pictures”
if filecmp.cmp(source_file, destination_file):
# Files are equal, so delete the source file
import os
os.remove(source_file)
else:
# Files are different or the destination file is missing, so move the source file to the destination
shutil.move(source_file, destination_file)
This is my results:
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘MoverII’ is not defined