0

Are there any particular libraries/modules I should use for this other than OS? I'm a beginner.

I have multiple directories which contain backups of many files ("organized" in a chaotic mix of many directories and files). Some of the files are unique, but most of the files are duplicates. I have some of the files on my hard drive already, but not all of them.

I want to gather all the unique files from the backups. If I already have these files (name is the same, file type is the name, file size is the same), then I can delete the backup file. If I do not yet have the backed up file, then I want to move it into my hard drive. In the end, I will destroy the backups, and my hard drive will have one copy of every file with no duplicates.


Here is an example:

My Hard Drive contains the following files: [apple, banana, pear]
Backup A contains the following files: [apple, pear, peach, tomato, carrot]
Backup B contains the following files: [apple, banana, pear, peach, tomato, carrot, potato]
Backup C contains the following files: [apple, banana, pear, peach, tomato, carrot, potato, celery]

In the above example, my program would first copy peach, tomato, and carrot from Backup A to My Hard Drive, and then delete Backup A. Then it would copy potato from the second hard drive, and delete Backup B. Then it would copy celery from Backup C, and delete Backup C.

1 Answer 1

1

I think that the best case would be to go to Python documentation and visit:

  1. os module

  2. os.path module

  3. shutil module

Those three should be sufficient for all of file operations that I see in Your question. But beware of destructive nature of the code that You will write as any kind of snippet potentially mess up Your files.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.