Von: Jan Erik Moström <[EMAIL PROTECTED]>
Datum: 28. Oktober 2006 15:55:21 MESZ
Betreff: Spotlight and indexing of text files


If I've understood things correctly Spotlight indexes files that have the extension "txt" or the file type "TEXT". BBEdit creates files with file type "TEXT" but I would like to start using a custom extension and sometimes these files will not have a file type (or should I say the empty file type). Anyway, I suppose I need to write a custom importer for Spotlight ... but a) being lazy, b) having never used XCode or Objective-C, I would like to ask if someone already have written such an importer that I could copy and modify?


A simple modification of the the RichText.mdimporter is needed. First find the type (according to Spotlight) of the files you want indexed using this command in the Terminal:
mdimport -n -d1 theFileName.ext

which outputs something like:
Import 'theFileName.ext' type 'someSpotlightType' no mdimporter

Now take that file type (someSpotlightType) and add it to the Info.plist file located at:
/System/Library/Spotlight/RichText.mdimporter/Contents/Info.plist.

Add it in the array for LSItemContentTypes:
<key>CFBundleDocumentTypes</key>
  <array>
    <dict>
     <key>CFBundleTypeRole</key>
          <string>MDImporter</string>
     <key>LSItemContentTypes</key>
     <array>
          <string>someSpotlighType</string>
          <string>public.rtf</string>
          <string>public.html</string>
          <string>public.xml</string>
          <string>public.plain-text</string>
          <string>com.apple.traditional-mac-plain-text</string>
          <string>com.apple.rtfd</string>
          <string>com.apple.webarchive</string>
     </array>
   </dict>
  </array>
Now go back to the Terminal and import the files in question (mdimport /PathToFiles/ToImport), or you can even re-import everything (sudo mdimport /). To see what is going on, add the -d1 switch to the mdimport command. Now Spotlight will be able to handle the new file types -- add as many as you like. Of course, you want to make sure that you only add files that are in fact text files!



---------------------------

  |||
a¿ex



--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to