0

This question already has an answer here:

/dir/ect/ory/ contains n folders each containing r files. Of which a certain number are the same file with a different file extension. These files are both in the same folder.

Is there a simple way to remove one file type but keep the other only a duplicate exists?

For example:

  /dir/ect/ory/1/myfile1.foo  
  /dir/ect/ory/1/myfile1.bar  
  /dir/ect/ory/1/myfile2.foo  
  /dir/ect/ory/1/myfile3.bar  
  /dir/ect/ory/2/myfile4.foo  
  /dir/ect/ory/2/myfile4.bar

Running the command would look something like the following:

duplicate-remove --recursive /dir/ect/ory/ --keep=*.bar

and would produce the result:

  /dir/ect/ory/1/myfile1.bar  
  /dir/ect/ory/1/myfile2.foo  
  /dir/ect/ory/1/myfile3.bar  
  /dir/ect/ory/2/myfile4.bar   

As you can see, I'm left with file1, file2, file3, file4 and no duplicates, but not all the files called *.foo were deleted, only the file with a *.bar duplicate.

Note also that it is only the file name I'm interested in comparing, not the the file size or data.

(A GUI program would be ok also)

marked as duplicate by Lucio, user117103, Alvar, Eric Carvalho, Avinash Raj Dec 23 '13 at 6:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • See here: askubuntu.com/questions/48524/… – Frantique Jan 31 '13 at 10:30
  • It isn't a duplicate of "How to find (and delete) duplicate files" because the files aren't duplicated, they're different files, some are compressed, some a different quality. It looks like it might be a duplicate of "Search for duplicate file names within folder hierarchy?" in @Frantique's comment. – Jamie Twells Jan 31 '13 at 20:39
  • 1
    See my link! It seems to me that it is what you are searching for! – Frantique Feb 1 '13 at 8:54