10.4: Find potential duplicate files via Spotlight metadata

Oct 13, '06 07:30:03AM

Contributed by: deef

I often rename files immediately after downloading and stick them in a folder somewhere for later reference. But I also often forget what I've already downloaded. So I wrote this bash shell script to use Spotlight to find files that match a file's name or its size and kind.

Usage, in Terminal:

dupecheck filename
For example, for a file called 0.pdf, output might look like this (line breaks added for a narrower display):
Possible matches based on filename:
/Users/whoever/Desktop/0.pdf
Possible matches based on size and kind:
/Users/whoever/Desktop/0.pdf
/Users/whoever/Desktop/Data/anthro articles/sahlins-1999.pdf
/Users/whoever/Desktop/Data/html/oldcourses/
 intro/secure/sahlins-sweetness.pdf
/Users/whoever/Documents/archives/another backup/
 blahblah/public_html/intro/secure/sahlins1999-sweetness.pdf
/Users/whoever/Desktop/Data/html/blahblah/readings/3/sahlins99.pdf
So it turns out I just downloaded a file that I already have four copies of under different names and locations.

I've set this up as a command in OnMyCommand. For this to work, it requires you to have put the shell script in a folder that's included in your $PATH. Here's the OnMyCommand command (assuming you are using OMCEdit):
cd __OBJ_PARENT_PATH__
dupecheck __OBJ_NAME__
Execution Mode should be set to Terminal.

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20061003163429425