Find symbolic links (’s names) with Spotlight (Finder) underwhelmed by the fact that OS X’s Aliases got really big with Mountain Lion (Lion?) I basically switched to using symbolic links instead.

Now I’m just learning the hard way that Spotlight (or, Finder for that matter; since Finder’s find relies on Spotlight) doesn’t index symbolic links (or, their names). I.e., when you look for a specific string/word in the name of a symbolic link (by way of Finder’s search-field) nothing shows up. This is different from Aliases (’s names), which do show up.

This is very bad for me and I’m looking for a way to make Spotlight index symbolic links (some mdimporter magic?), or to be able to search for (the names of) symbolic links in some other way.

You see, I’m using the symbolic links mostly to link to larger files that reside on eternal hard drives in order to save space on my internal drive. But I really need to find these files (by searching their respective folders) by entering some search term that matches their name.

I’m searching for (the names of) the linked files, not for the symbolic link-files themselves; that’s why a solution like proposed here:

http://arstechnica.com/civis/viewtopic.php?f=19&amp;t=1109635

doesn’t help me. If I understand correctly.

Over the last weeks (after switching to Mountain Lion from Snow Leopard) I created lots of symbolic links that are now invisible to any search functionality.
You can use the find command to show you the target of the symlink then have awk throw away the rest of the line.  Then wrap that in a loop that tells you what it's doing then feeds the names to mdimport:

for linktarget in $(find ${HOME} -type l -ls | awk -F'-&gt; ' '{print $NF}'); do
    echo "importing ${linktarget}"
    mdimport "${linktarget}"; 
done


It's probably easier to cut and paste this little script since there are some spaces that are easy to miss.  (like the one after the arrow in the awk statement).