Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Make home Library sub-folders available to Spotlight System
Here's one approach to making items in your home Library folder searchable in Spotlight.

Spotlight searches exclude items that exist in the user's home Library folder (now hidden by default). There are some items that normally reside in the home Library folder that I want to be available for my Spotlight searches. Rather than trying to find a hack to defeat the system's exclusion of the home Library folder for Spotlight, I use a method that doesn't require crossing the boundaries of what the OS permits users to do.

I simply select folders, the contents of which I would like to appear in Spotlight searches, such as Scripts and Favorites, move them up a level to the home folder, then create a symbolic link to the moved item to serve as a substitute for it in its original location. I'm including source for an AppleScript droplet that I use to automate this process. If your Library folder is already open (one way to open it is to hold down the Option key then select it from the Go menu in the Finder), just drop one or more of its folders onto the droplet. If you double-click the droplet created from the AppleScript, it will open your Library folder so that you can drop one or more folders into the ensuing dialog box.
on open the_items
        my up_one_leave_link(the_items)
end open

on up_one_leave_link(the_items)
        display dialog "This will move dropped folders
up one directory and substitute symbolic links
that point to their new location.

Is that what you want to do?"
        repeat with the_item in the_items
                set the_item to the_item as alias
                tell application "Finder"
                        set sost to ((container of folder 
                                (the_item as string)) as alias) as string
                        set sost_Parent to (container of folder 
                                (sost as alias))
                end tell
                set sost to POSIX path of sost
                set sost_Parent to POSIX path of (sost_Parent as string)
                set this_filepath to (the_item as string)
                if last character of this_filepath is ":" then
                        tell me to set it_is_a_folder to true
                        set it_is_a_folder to false
                end if
                set thesourcename to (name of (info for the_item))
                set the_source_file to POSIX path of this_filepath
                set pos_filepath to sost
                if it_is_a_folder then
                                set my_command to "mv" & 
                                        space & (quoted form of the_source_file) 
                                        & space & (quoted form of sost_Parent)
                                set my_command to my_command & 
                                        ";ln -s" & space & (quoted form of sost_Parent) 
                                        & (quoted form of thesourcename) & space & (quoted form of sost)
                                do shell script my_command
                        on error onerr
                                display dialog onerr
                        end try
                        display dialog "Folders only, please!"
                end if
        end repeat
end up_one_leave_link

on run
        display dialog "This will move selected folders
up one directory and substitute symbolic links
that point to their new location.

Is that what you want to do?"
        do shell script "open ~/Library"
        do shell script "sleep 1"
        set the_items to ((choose folder) as list)
end run
[kirkmc adds: Paste the above script in AppleScript Editor, then save it as an application. This solution should work, but be careful if, after an OS X update, something is broken.]
  • Currently 2.63 / 5
  You rated: 4 / 5 (8 votes cast)

Make home Library sub-folders available to Spotlight | 3 comments | Create New Account
Click here to return to the 'Make home Library sub-folders available to Spotlight' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Make home Library sub-folders available to Spotlight
Authored by: diorite on Nov 29, '12 12:03:39PM

I have the user library set to show up on my machine, but I'm curious if setting the "kind" popup in a Spotlight window to "System files" ---> "Are included" would do the same thing as this hint?

I think I remember using that before I un-hid my user library, and it worked.

Just curious.

[ Reply to This | # ]
Make home Library sub-folders available to Spotlight
Authored by: llee on Nov 29, '12 12:42:10PM
I believe so, and I have a great number of custom searches. I think it would be terrific to be able to customize the default search using tokens as well as categories, but it appears that the user interface folks at Apple have reached a different conclusion.

[ Reply to This | # ]
Make home Library sub-folders available to Spotlight
Authored by: szedula on Nov 30, '12 11:19:18AM

I thought selecting "Other..." in the Spotlight search and then scrolling down to the "System files" attribute would allow searching Library sub-folders. The description (in Snow Leopard) reads "Include system files, such as preferences and plug-ins". I'm not at my Lion system but I though I had also performed that type of search on that system as well. I want to do that type of search often enough that I've also checked "In Menu" so I can search those files more easily. I just wish I could change the default from "aren't included" to "are included".

[ Reply to This | # ]