How to compare two directories and remove the difference in files
Posted on 2004-04-20
What I want to do is this:
I have 2 directories 'image' & 'thumbnail' and I want to compare the 2 directories *recursively* so that I can find the files that are still in 'thumbnail' but not in 'image'. Please note that I just want to compare the filenames (ie doesn't matter if their sizes are different). Then I want to delete the files that are still in 'thumbnail' but not in 'image'.
At the moment I have experimented with diff command such that:
'diff -r image thumbnail'
Binary files image/009.jpg and thumbnail/009.jpg differ
Only in thumbnail: 010.jpg
Binary files image/sunset.jpg and thumbnail/sunset.jpg differ
I only want to 'capture' the second line of the output (i.e. Only in thumbnail) and remove (rm -rf) those file(s).
Thanx for your help in advance