<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>toxicsoftware.com &#187; Spotlight</title>
	<atom:link href="http://toxicsoftware.com/tag/spotlight/feed/" rel="self" type="application/rss+xml" />
	<link>http://toxicsoftware.com</link>
	<description>RANDOMIZE USR 0</description>
	<lastBuildDate>Sun, 01 Aug 2010 17:49:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Internet Clippings to XBEL</title>
		<link>http://toxicsoftware.com/internet-clippings-to-xbel/</link>
		<comments>http://toxicsoftware.com/internet-clippings-to-xbel/#comments</comments>
		<pubDate>Sat, 03 Jun 2006 16:36:05 +0000</pubDate>
		<dc:creator>schwa</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[mdfind2]]></category>
		<category><![CDATA[Spotlight]]></category>
		<category><![CDATA[WebNoteHappy]]></category>
		<category><![CDATA[xbel]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://toxicsoftware.com/internet-clippings-to-xbel/</guid>
		<description><![CDATA[I have thousands of Mac OS X url clippings files on my mac. These little files are reported by the finder as &#8220;Web Internet Location&#8221; files. They&#8217;re sometimes known as &#8220;weblocs&#8221; (due to their file extension) and look like this: &#8230; <a href="http://toxicsoftware.com/internet-clippings-to-xbel/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have thousands of Mac OS X url clippings files on my mac. These little files are reported by the finder as &#8220;Web Internet Location&#8221; files. They&#8217;re sometimes known as &#8220;weblocs&#8221; (due to their file extension) and look like this: <img src="/uploads/Webloc.png" alt="Webloc.png" /></p>

<p>The reason I have so many of these things is that I switch browsers relatively frequently (bouncing between Safari and OmniWeb and occasionally Firefox) and I find weblocs are more permanent and just more convenient than browser bookmarks.</p>

<p>Mostly they&#8217;re &#8220;organised&#8221; into a single folder and I use Spotlight to find the ones I am interested in at that moment. However Spotlight doesn&#8217;t have a default webloc metadata importer, and this is where Toxic Software stands up to fill the gap. My <a href="/blog/spotlight-importer-collection/">Spotlight Importer Collection</a> package includes three importers, one of which as luck would have it is a webloc importer (in fact it also imports a plethora of other internet clipping files: afploc, fileloc, ftploc, inetloc, mailloc, urlloc and webloc).</p>

<p>After installing Toxic URL Importer and waiting for Spotlight to index your volumes each webloc (if you&#8217;re in a rush use mdimport to force Spotlight to index files immediately) you&#8217;ll be able to view a webloc&#8217;s URL directly in the finder: <img src="/uploads/WeblocInfo.png" alt="WeblocInfo.png" /></p>

<p>From Terminal.app you can use mdls to inspect the extra metadata added to the file by Toxic URL Importer:</p>

<pre><code>[schwa@cobweb] Desktop$ mdimport The\ XML\ Bookmark\ Exchange\ Language\ Resource\ Page.webloc 
[schwa@cobweb] Desktop$ mdls The\ XML\ Bookmark\ Exchange\ Language\ Resource\ Page.webloc 
The XML Bookmark Exchange Language Resource Page.webloc -------------
kMDItemContentType                    = "com.toxicsoftware.webloc"
kMDItemContentTypeTree                = (
    "com.toxicsoftware.webloc", 
    "com.toxicsoftware.urlloc", 
    "public.url", 
    "public.data", 
    "public.item"
)
kMDItemDisplayName                    = "The XML Bookmark Exchange Language Resource Page.webloc"
kMDItemID                             = 17168962
kMDItemKind                           = "Web Internet Location"
kMDItemURL                            = "http://pyxml.sourceforge.net/topics/xbel/"
org_spotlightdev_digest_sha1          = "794043e7673e525d654e7b8e4115636408182528"
org_spotlightdev_metadata_mdimporters = ("com.toxicsoftware.url-importer")
org_spotlightdev_metadata_url_host    = "pyxml.sourceforge.net"
org_spotlightdev_metadata_url_scheme  = "http"
org_spotlightdev_metadata_urls        = ("http://pyxml.sourceforge.net/topics/xbel/")
</code></pre>

<p>You can then search for weblocs by host or by scheme or a by any text in the url. Very handy:</p>

<p><img src="/uploads/Spotlight.png" alt="Spotlight.png" /> On the whole using weblocs and Spotlight together is a great solution. But I think I&#8217;ve found a better one. Luis de la Rosa&#8217;s <a href="http://www.happyapps.com/">WebNote Happy</a> is a fantastic application for managing bookmarks. It allows me to manage my bookmarks in a single window (like my folder of weblocs) and integrates really well with <a href="http://del.icio.us/">del.icio.us</a>. As fast as Spotlight searching is, WebNoteHappy beats it hands down with lightning fast searches.</p>

<p>Unfortunately WebNoteHappy doesn&#8217;t yet import or export webloc files (Luis is a very responsive developer and am sure will be making up for this minor deficiency in later releases). But fortunately WebNoteHappy does import <a href="http://pyxml.sourceforge.net/topics/xbel/">XBEL</a> files, which as I&#8217;ve already written about in my post about <a href="/blog/converting-omniweb-bookmarks-to-xbel-for-webnotehappy/">OmniWeb and XBEL</a> is a very handy intermediate file format.</p>

<p>As it turns out I have almost all the tools necessary to get my thousands of weblocs files into WebNoteHappy. I have <a href="/blog/mdfind2-updated/">mdfind2</a>, which like its little cousin <a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/mdfind.1.html">mdfind</a> can perform Spotlight searches from the terminal. However mdfind2 can also export an XML file describing the metadata of the found items. All I needed to do was use mdfind2 to find all my webloc files and then transform the XML into XBEL via a custom written XSLT.</p>

<p>Here is the XSLT file &#8220;mdfind2_to_xbel.xsl&#8221;:</p>

<pre><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;  
&lt;xsl:stylesheet version="1.0"  
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;  

    &lt;xsl:output method="xml" indent="yes" doctype-public="+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" doctype-system="http://www.python.org/topics/xml/dtds/xbel-1.0.dtd"/&gt;  

    &lt;xsl:strip-space elements="*"/&gt;  

    &lt;xsl:template match="/"&gt;  
        &lt;xbel version="1.0"&gt;  
            &lt;xsl:apply-templates/&gt;  
        &lt;/xbel&gt;  
    &lt;/xsl:template&gt;  
    &lt;xsl:template match="item"&gt;  
        &lt;bookmark&gt;  
            &lt;xsl:attribute name="href"&gt;&lt;xsl:value-of select="attributes/attribute[@key='kMDItemURL']"/&gt;&lt;/xsl:attribute&gt;  
            &lt;xsl:attribute name="id"&gt;_&lt;xsl:value-of select="attributes/attribute[@key='kMDItemID']"/&gt;&lt;/xsl:attribute&gt;           &lt;xsl:attribute name="added"&gt;&lt;xsl:value-of select="attributes/attribute[@key='kMDItemContentCreationDate']"/&gt;&lt;/xsl:attribute&gt;  
            &lt;xsl:attribute name="modified"&gt;&lt;xsl:value-of select="attributes/attribute[@key='kMDItemContentModificationDate']"/&gt;&lt;/xsl:attribute&gt;  
            &lt;xsl:attribute name="visited"&gt;&lt;xsl:value-of select="attributes/attribute[@key='kMDItemLastUsedDate']"/&gt;&lt;/xsl:attribute&gt;  
            &lt;title&gt;&lt;xsl:value-of select="name"/&gt;&lt;/title&gt;  
        &lt;/bookmark&gt;  
    &lt;/xsl:template&gt;  
    &lt;xsl:template match="text()"&gt;&lt;/xsl:template&gt;  

&lt;/xsl:stylesheet&gt;
</code></pre>

<p>And here is the tiny snippet of shell script needed to tie it all together:</p>

<pre><code>mdfind2 --xml "kMDItemContentTypeTree == 'com.toxicsoftware.urlloc'" | \  
xsltproc mdfind2_to_xbel.xsl -  
</code></pre>

<p>And here is the final resulting XBEL file (limited to just a single entry) ready to be imported in WebNoteHappy:</p>

<pre><code>&lt;?xml version="1.0"?&gt;  
&lt;!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://www.python.org/topics/xml/dtds/xbel-1.0.dtd"&gt;  
&lt;xbel version="1.0"&gt;  
  &lt;bookmark href="http://www.txrollergirls.com/teams.htm" id="_9799996" added="2005-02-17 13:54:05 -0500" modified="2005-02-17 13:54:05 -0500" visited="2005-02-17 13:54:05 -0500"&gt;  
    &lt;title&gt;texas rollergirls TEAMS&lt;/title&gt;  
  &lt;/bookmark&gt;  
&lt;/xbel&gt;  
</code></pre>

<p>After running the script I now have all my weblocs safely imported into WebNoteHappy, with duplicates removed (in fact they were never imported in the first place). I can tag them and add them to del.ici.ous with just a click, and I can now import my current Safari bookmarks into the list and manage <em>all</em> my bookmarks in one place.</p>

<p>Using a little bit of custom coding (my URL Importer, mdfind2 and the XSLT) I was able to use the extensibility of Spotlight and WebNoteHappy to my advantage. A sure sign of how useful a piece of software is how easy it is to be extended by its end users.</p>

<p>Subversion Repository: <a href="http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Projects/Misc/mdfind2_to_xbel">http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Projects/Misc/mdfind2_to_xbel</a></p>
]]></content:encoded>
			<wfw:commentRss>http://toxicsoftware.com/internet-clippings-to-xbel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mdfind2 updated</title>
		<link>http://toxicsoftware.com/mdfind2-updated/</link>
		<comments>http://toxicsoftware.com/mdfind2-updated/#comments</comments>
		<pubDate>Sat, 03 Jun 2006 15:22:11 +0000</pubDate>
		<dc:creator>schwa</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[mdfind]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Spotlight]]></category>

		<guid isPermaLink="false">http://toxicsoftware.com/mdfind2-updated/</guid>
		<description><![CDATA[I&#8217;ve just updated mdfind2. The most important change is that it is now a universal binary. I&#8217;ve also improved the command-line parsing (it now uses getopt_long) and prints usage information on error. Links: Subversion Repository: http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Spotlight/mdfind2/ Binary: http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Spotlight/mdfind2/Output/mdfind2.tar.bz2]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just updated <a href="/blog/mdfind2">mdfind2</a>. The most important change is that it is now a universal binary. I&#8217;ve also improved the command-line parsing (it now uses getopt_long) and prints usage information on error.</p>

<p>Links:</p>

<p>Subversion Repository: <a href="http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Spotlight/mdfind2/">http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Spotlight/mdfind2/</a></p>

<p>Binary: <a href="http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Spotlight/mdfind2/Output/mdfind2.tar.bz2">http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Spotlight/mdfind2/Output/mdfind2.tar.bz2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://toxicsoftware.com/mdfind2-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spotlight Importer Collection</title>
		<link>http://toxicsoftware.com/spotlight-importer-collection/</link>
		<comments>http://toxicsoftware.com/spotlight-importer-collection/#comments</comments>
		<pubDate>Mon, 29 May 2006 19:46:20 +0000</pubDate>
		<dc:creator>schwa</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[Spotlight]]></category>
		<category><![CDATA[toxicsoftware.com]]></category>

		<guid isPermaLink="false">http://toxicsoftware.com/spotlight-importer-collection/</guid>
		<description><![CDATA[Today I&#8217;m announcing some code that has actually been on my public subversion repository for some time. The Spotlight Importer Collection is a set of three Spotlight Importers. The first importer is &#8220;Toxic Configuration Importer&#8221;. This imports most plain-text based &#8230; <a href="http://toxicsoftware.com/spotlight-importer-collection/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;m announcing some code that has actually been on my public subversion repository for some time. The <a href="http://toxic-public.googlecode.com/svn/tags/BlogTag_20070927_729/Projects/Spotlight/Spotlight%20Importer%20Collection/">Spotlight Importer Collection</a> is a set of three Spotlight Importers.</p>

<p>The first importer is &#8220;Toxic Configuration Importer&#8221;. This imports most plain-text based unix config files and Mac OS X plist files.</p>

<p>The second importer is &#8220;Toxic Logfile Importer&#8221;. This imports all &#8220;.log&#8221; files as plain text. You can use Smart Folders to monitor your log files from the Finder. Beware that this is can be very expensive (log files are updated a lot).</p>

<p>The final importer is &#8220;Toxic URL Importer&#8221;, this code imports URL clippings. These are the files you get when dragging a URL from an application to the Finder. This is probably the most useful importer of the three and I&#8217;ll be making a follow-up post just for this importer later.</p>

<p>Download a <a href="http://toxic-public.googlecode.com//archives/SpotlightImporterCollection.dmg">disk image</a> with installers with all three importers.</p>
]]></content:encoded>
			<wfw:commentRss>http://toxicsoftware.com/spotlight-importer-collection/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
