Archive for ‘spotlight’ Category
Browse:
spotlight »
Subcategories:

CLI commands that let you access meta data of all files in OSX

datePosted on 14:29, July 31st, 2012 by Many Ayromlou

Two small commands with huge possibilities:

  1. mdls 
    usage: mdls [-name attr] [-raw [-nullMarker markerString]] [-plist file] path
    list the values of one or all the attributes of the specified file
    -raw: don't print attribute names before values
    -nullMarker: substitute this string for null attributes in raw mode
    -plist: output attributes in XML format to file. Use - to write to stdout
    option -plist is incompatible with options -raw, -nullMarker, and -name
    example: mdls ~/Pictures/Birthday.jpg
    example: mdls -name Keyword ~/Pictures/Birthday.jpg
  2. mdfind
    Usage: mdfind [-live] [-count] [-onlyin directory] [-name fileName | -s smartFolderName | query]
    list the files matching the query
    query can be an expression or a sequence of words
    
    	-live             Query should stay active
    	-count            Query only reports matching items count
    	-onlyin <dir>     Search only within given directory
    	-name <name>      Search on file name only
    	-s <name>         Show contents of smart folder <name>
    	-0                Use NUL (``\0'') as a path separator, for use with xargs -0.
    
    example:  mdfind image
    example:  mdfind -onlyin ~ image
    example:  mdfind -name stdlib.h
    example:  mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'"
    example:  mdfind -live MyFavoriteAuthor

How to turn Spotlight OFF (and ON Again)….Leopard Solution

datePosted on 20:01, January 14th, 2009 by Many Ayromlou

A number of people mentioned that the previous tip on how to turn spotlight on/off does not work with Leopard. Now that I’ve had a bit of time, I’ve confirmed this and found a way around it (it’s even easier in Leopard). Here are the details specifically for OSX 10.5+ (Leopard).

  • To turn off Spotlight service temporarily
  • % sudo launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

  • To turn off Spotlight service permanently (no worries, you can turn it on again)
  • % sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

  • To turn on Spotlight service temporarily
  • % sudo launchctl load /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

  • To turn on Spotlight service permanently
  • % sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Have fun….

How to turn Spotlight OFF (and ON Again)….

datePosted on 16:06, August 1st, 2007 by Many Ayromlou
UPDATE: Please see this article if you use Leopard (OSX 10.5+). The procedure below, although not damaging, works for 10.4 and below (Tiger). Thanks to Anonymous for pointing this out.

Got a new Macbook thru work today and after Firewire targeting my profile over from my personal MBP, I started looking around the blog for the entry that shows you how to turn off Spotlight. You see Spotlight is a good idea, but I think it needs a bit more work. I’ve noticed that on my MBP and older Dual G5 machines, the mds service sometimes just goes nuts (usually corrupt files or something like that), and brings the machine to a halt. So I like to turn Spotlight off ASAP. Here is how:

  • Edit /etc/hostconfig (don’t forget to sudo) and change the line that reads
    SPOTLIGHT=-YES-
    to
    SPOTLIGHT=-NO-
  • Run the following two commands from the command line to get rid of existing index files
    sudo mdutil -i off /
    sudo mdutil -E /
  • Reboot

Note that the crazy spotlight icon will still be there, but the backend (the bad stuff) will be disabled after the reboot. You can optionally kill the icon (not recommended) by issuing the command:
sudo chmod 0000 /System/Library/CoreServices/Search.bundle
Later on if you want to turn spotlight back on (why?) you can do it by doing the following:

  • Edit /etc/hostconfig (don’t forget to sudo) and change the line that reads
    SPOTLIGHT=-NO-
    to
    SPOTLIGHT=-YES-
  • Reboot
  • Run the following command from the command line to turn on indexing
    sudo mdutil -i on /

Enjoy….