adrianlopezroche / fdupes

FDUPES is a program for identifying or deleting duplicate files residing within specified directories.
2.42k stars 186 forks source link

Prioritize directory to delete folders from #183

Open sylvainsab opened 4 months ago

sylvainsab commented 4 months ago

I often meet this problem : I have an archive/stock folder, which files get dispatched/ordered/classified towards various sub- or other directories. I would like to scan for duplicates and delete the duplicates only from said root/stock folder.

I imagine something like this (for an album pictures folder) :

$ ls
stock wedding christmas birthday_party
$ fdupes -rd . -P stock

And in the manpage

-P --prior folder[,folder2...]
only delete files from given folders

I suppose this is already doable with the available options, but more risky/sketchy and not very straightforward. The manpage could do with some more examples. I might pull a request to the man if I find a way. Thank you.

VD171 commented 3 months ago

Any solution?

skitchin commented 1 month ago

Here's how you can delete duplicates without removing files from a specific directory. You'll use the -o option with double slashes with full path to set the priority order. For example:

fdupes -rdN -o name //pictures/photo1 /pictures/photo2

This command will delete duplicates found in the photo2 directory, keeping the files in photo1.

If you have three or more directories, add slashes in the order of priority. For instance, with four directories:

fdupes -rdN -o name ////pictures/photo1 ///pictures/photo2 //pictures/photo3 /pictures/photo4

This setup ensures that any duplicates found in photo1 and photo2 will be deleted from photo2. Similarly, duplicates found in photo2 and photo4 will be deleted from photo4.

I hope this helps.