posts:node: Add a post on Node and npm
[blog.git] / posts / find_duplicates.mdwn
1 [[!meta  title="find_duplicates"]]
2
3 I've reorganized my music a few times, and it took me a while to get
4 organized enough to want a single directory tree that held everything
5 I owned.  Every once and a while I go through the junk drawer and move
6 a few more songs into the "official" tree, checking their metadata and
7 whatnot.  I was getting annoyed at finding duplicate songs in several
8 junk drawers, so I wrote up a little script, [[find_duplicates.py]]
9 which can compare SHA1s for files in two trees and remove any
10 duplicates from the lesser tree.  Now there is a lot less junk to merge
11 into my official tree.
12
13 Sometimes you want to do something more effective than printing
14 duplicates, but more subtle than removing them.  To give you this
15 flexibility, I've added the `--one-line` option, which you can use
16 along these lines:
17
18     $ find_duplicates.py dir_a dir_b --one-line | while read -a DUPS; do mv "${DUPS[1]}" "${DUPS[0]}".dup; done
19
20 [[!tag tags/code]]
21 [[!tag tags/fun]]
22 [[!tag tags/python]]