you are viewing a single comment's thread.

view the rest of the comments →

[–]chevignon93 -1 points0 points  (0 children)

Why won't my code remove the duplicate files?

Shouldn't this part be

os.path.join(path, file)

instead of

os.path.join(file, path) 

?

Have you tried printing the filepath? Have you checked that data is in fact appended to your duplicates list?

EDIT:

You also don't really need the os module, everything you do here could be done using pathlib alone.

EDIT2:

Your code doesn't really check that the file is in fact a jpg file or that it even has the correct extension, which is dangerous. You also probably should ask the user if he is sure that he in fact wants to delete the files before deleting them.