I have an archived folder, named "dir1".
I have an new data folder, named "dir2".
I have a differences folder, named "dir3".
The data are jpgs, there are no sub folders.
dir1
1.jpg
2.jpg
3.jpg
4.jpg
dir2
1.jpg (edited file)
2.jpg (edited file)
3.jpg (same file as in dir1)
4.jpg (same file as in dir1)
5.jpg (new file)
6.jpg (new file)
I need to move the new, missing, edited and differing files to dir3.
The result would be:
dir3
1.jpg
2.jpg
5.jpg
6.jpg
Here is what i have:
from filecmp import dircmp
dcmp = dircmp('dir1', 'dir2')
def main(dcmp):
for name in dcmp.diff_files, dcmp.right_only:
print (name)
if __name__ == "__main__":
main(dcmp)
The result is:
['2.jpg', '1.JPG']
['6.jpg', '5.jpg']
Insted of "print", how do i move these to dir3.
I've tried "shutil" and "os.rename", but i cant get it to work.
Information from "filecmp" and "dircmp".
import filecmp
filecmp.dircmp('dir1', 'dir2').report()
The result is:
diff dir1 dir2
Only in dir2 : ['5.jpg', '6.jpg']
Identical files : ['3.JPG', '4.JPG']
Differing files : ['1.JPG', '2.jpg']
This is just fyi.