Find your files on Mac

I love Spotlight on Mac but wanted to explore a few other tools. Here are a few of my favorites.

DocFetcher

I really like DocFetcher. It's a Java program that runs on all Operating Systems and you can even put it on a USB with an index that leads to other files on the USB. DocFetcher can index all sorts of files including PDF, Microsoft Office, ID3 tags within an MP3. I found it easier to work with then beets.

DocFetcher
Download DocFetcher for free. Desktop search application. DocFetcher is an Open Source desktop search application: It allows you to search the contents of files on your computer. — You can think of it as Google for your local files.

mdfind

mdfind is the Terminal equivalent of Spotlight. It's very powerful and most important of all, scriptable. Below are a few common commands.

mdfind -name rails
Search your entire Mac for everything with "rails" in the name.
mdfind "rails" -onlyin ~/Documents/
Search for text within a specific directory.
mdfind "kind:image date:yesterday"
Return image files that were edited yesterday.
mdfind 'kMDItemFSCreationDate < $time.today(0) && kMDItemFSCreationDate > $time.today(-1) && kMDItemKind = *image'
Return image files between yesterday and today.

ACK

ack is a search tool designed for code. It's built to be a customizable replacement for grep with higher speed,  automatic recursion, and is able to skip unimportant files.

brew install ack
Install ACK using Homebrew
ack rails
Search your entire Mac for everything with "rails" in the name.
ack --js vue
Search JavaScript files that use the keyword vue.

Find

find . -type f -exec grep -l rails {} +
Search your entire Mac for everything with "rails" in the name.
find <~/Documents> -iname "*.<filetype>"
Find by file type within a directory.
 find #{dir} -type f -name "*.#{type}" 2>/dev/null
Find by filetype and ignore error messages.

Grep

Grep is not my favorite replacement to Spotlight but it has its use cases. Warning: This may take a very long time.

grep -r "rails"
Search your entire Mac for everything with "rails" in the name.
grep -r -l "rails" ~/Documents/
Search for text within any file within your Documents directory.

Resources