Nifty Box News

Sunday, December 10, 2006

New feature for 1.1: Spotlight export

The last couple of weeks I've working on the export of tags and comments to Spotlight. This has been much more complicated than I expected. Nifty Box now writes the tags or comments to the Spotlight Comment field in the Finder's "Get Info..." window (for file items). This is a bit tricky.

First of all only the Finder can edit this field, which means one has to use AppleScript or AppleEvents. This is ok, there exists some source code from Apple (MoreFinderEvents) to do this. But during the testing sometimes strange things happened: for long comments written to this field it seems, that the Finder looses information about all the comments and icon positions in the folder of the changed item. After some experimenting I found, that the Spotlight Finder comment is written to the hidden .DS_Store file in the folder of the specific file. The .DS_Store contains all specific Finder information (like icon position and Spotlight comments) of all the files in the folder. But this information is somehow coded in blocks, which means that there is a maximum length set implicitly for the Spotlight comments. If you try to save a longer comment, the .DS_Store gets corrupted. By trial-and-error I concluded, that the combined length of the comment plus the length of the filename must not be greater than 1012 UTF-16 characters. Nifty Box will deal with this. For web bookmarks I dont use the Spotlight comment field, but provide an own Spotlight importer, which is much more convenient.

The way the Spotlight finder comments are used by Nifty Box is as follows: first all tags are written into the field, whereby these can be prefixed by a special character like "|" or "&". If you choose to use such a prefix, the Spotlight search can be narrowed down only to the Nifty Box items. An example: if you like to search in Spotlight for items tagged with "Apple" you would get a zillion hits if you just type in "Apple" in the search field, because - as you might guess - the word "Apple" can be found quite a lot on the mac. But if you only want to view the Nifty Box items, tagged with "Apple", you can define just a tag prefix like "|" and search in Spotlight for "|Apple" which should only give you the Nifty Box items.

After the tags you can choose to export your notes too. At the end a marker "_nybx_" is inserted into the comment field. After this marker the original comment from the Spotlight comment field is preserved. If the complete string (Nifty Box additions plus original comment) gets too long for the .DS_Store file, the Nifty Box additions will be shortened leaving the original comment complete.

Just to give you an impression, here is the new preferences tab for the Spotlight Export settings:



This will export a Spotlight Finder comment like this:



And here is an example Spotlight search for the tag "Mars": (please note the prefix "|")

In the screenshot you can also see the tagged web bookmarks at the top, which are provided by an Spotlight importer and not via the Finder's Spotlight comment field.

Using the Finder's Spotlight comment field for the file items also gives you information directly in the Finder if a file is tagged by Nifty Box: you can activate the "Comments" table column in the Finder window, which will show you the tag information for all files in a given folder:



So this export functionality is now implemented and in beta test. I am now working on the second new feature for version 1.1. I hope I will finish the development in December such that the new version can be released at the beginning of the new year.

Labels:

7 Comments:

  • I curious as to why you chose Finder comments over custom metadata.

    Also, I suspect there are issues with Finder comments and network volumes: there is an Apple technical note here about how to turn .DS_Store creation off on network volumes, and on shared volumes, for example, I can see the logic.

    By Anonymous Miles Metcalfe, At 12/20/2006 2:12 AM  

  • Setting metadata for arbitrary file types is not easy as you cannot provide a dedicated Spotlight importer. You might enter tag metadata using the xattr file attributes, like SpotMeta. But in order to make these xattr tags searchable for Spotlight one has to run a daemon listening to changes on the filesystem (maybe via fsevents). I think SpotMeta is doing something like this.

    For Nifty Box I decided to use the Spotlight Comments fields. I think it's a good compromise: the user can easily see the tags and comments using the built-in Finder functionality. This also allows the nice tag display in the tabular view of the Finder as can be seen in the last screenshot above.

    You are right, that not every user wants the tags exported to network drives via the .DS_Store. In the current beta build I included a new preference setting such that only files on the local volume are tagged for Spotlight if the user wishes so.

    By Blogger Tim Scheffler, At 12/20/2006 12:15 PM  

  • Hi, I was just wondering if you have an updated release timeframe towards NiftyBox 1.1

    Best regards, TFS

    http://tfserna.ngsec.com

    By Anonymous Anonymous, At 1/27/2007 11:06 PM  

  • Hi!
    The coding of a new tag cloud view took much longer than I've expected. I hope to finish a beta version this week, which means the 1.1 should see the light of day in middle of February.
    The 1.1 release will be about Spotlight export and tag clouds. (And some minor design changes as usual).
    When the beta is available I will post a bit more information on the blog.

    By Blogger Tim Scheffler, At 1/28/2007 8:08 PM  

  • Great!
    Many thanks, TFS

    By Anonymous Anonymous, At 1/29/2007 9:40 PM  

  • "If the complete string (Nifty Box additions plus original comment) gets too long for the .DS_Store file, the Nifty Box additions will be shortened leaving the original comment complete." Is it a possibillity to make use of extra space bij creating an alias of that file? (leads to the same file en the comments area is empty again)

    By Blogger Ronald, At 12/29/2007 11:48 PM  

  • Hi Ronald,

    That's a nice idea!
    But the implementation might be a bit tricky. Right now I am working only a small amount of time on Nifty Box, due to other obligations, so I can't say when this feature will make it into NB, but I will definitely put it onto my to-do list.

    By Blogger Tim Scheffler, At 12/30/2007 11:42 AM  

Post a Comment



<< Home