r/programmingrequests • u/ProffesorCalculus • Jul 27 '17
[Request] A simple program to delete files that have their hexadecimal hash in their filenames
I've exported .csv and .html files of the results of the duplicate images generated by Similarity which is a decent free software. Now the problem is that there are about 15'000 images that have duplicates renamed with their hashes in Hydrus Network.
I'm looking to keep the files with their original filenames, not ones that are renamed to their hashes. I can manually do this in Similarity, but since there are 15K files, it'll take a lot of time so I'm requesting a simple code to do that for me.
Any helps would be much appreciated.
2
Upvotes
1
u/ProffesorCalculus Jul 28 '17
I used the second method (replacing
delwithmove)and it worked just fine!If I understood correctly, your code tells the computer to read the CSV file line by line and to calculate the hash of the each of the two files that are addressed in a line, then move/delete one of the addressed files which has the same filename as its calculated hash, right?
I'm going to delete the moved files, but just for a peace of mind, I'm gonna double check before that. What does the code do if there are two files in a line with the same 64 hex characters file name but one with a (1) after its name?
Is there a trustworthy way to code a program that would calculate the hash of every file in a folder, and do the same for files in another folder (two different folders thus two different directories) and then to delete the files that are repeated in the second folder?
I mean, I moved the files with your code to a folder named "moved". Now, I want to make sure that there is a copy of each file of "moved" in "xxx", and if the statement is true, then to delete that file from "moved".