<?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>devgrind &#187; mac</title>
	<atom:link href="http://devgrind.com/tag/mac/feed/" rel="self" type="application/rss+xml" />
	<link>http://devgrind.com</link>
	<description>thinking outside the { }</description>
	<lastBuildDate>Fri, 04 Nov 2011 10:42:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Scripting The Night Away</title>
		<link>http://devgrind.com/2008/08/01/scripting-the-night-away/</link>
		<comments>http://devgrind.com/2008/08/01/scripting-the-night-away/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 14:20:20 +0000</pubDate>
		<dc:creator>Magnus</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://devgrind.com/?p=47</guid>
		<description><![CDATA[One of the very nice features of Mac OS X ist the ability of almost every reasonable application to receive AppleEvents, which makes the whole OS-app-bundle highly scriptable. Normally, Apple recommends that the scripting is done using a malevolent, programmer-unfirndly language named &#8220;AppleScript&#8221;. But there are alternatives, e.g. using Ruby together with the rb-appscript library. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the very nice features of Mac OS X ist the ability of almost every reasonable application to receive AppleEvents, which makes the whole OS-app-bundle highly scriptable. Normally, Apple recommends that the scripting is done using a malevolent, programmer-unfirndly language named &#8220;AppleScript&#8221;. But there are alternatives, e.g. using Ruby together with the rb-appscript library.</p>
<p>As a first try, I wrote a small hack solving the following problem:</p>
<blockquote><p>In Aperture, I normally sort photos in folders named YYYY_MM_DD, so when I sort them by alphabet (or Aperture sorts them and I cannot change the sort order), the oldest ones show up first. Unfortunately, iPhoto imported photos from my camera in the German format DD.MM.YYYY, so the alphabetical sorting is useless.</p></blockquote>
<p>The ruby script goes like this:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw3">require</span> <span class="st0">&quot;rubygems&quot;</span><br />
<span class="kw3">require</span> <span class="st0">&quot;appscript&quot;</span><br />
<span class="kw1">include</span> Appscript</p>
<p>app = app<span class="br0">&#40;</span><span class="st0">&#8216;Aperture&#8217;</span><span class="br0">&#41;</span><br />
<span class="kw3">puts</span> app.<span class="me1">projects</span><br />
app.<span class="me1">get</span><span class="br0">&#40;</span>app.<span class="me1">projects</span><span class="br0">&#41;</span>.<span class="me1">each</span> <span class="br0">&#123;</span> |project|<br />
&nbsp; name = app.<span class="me1">get</span><span class="br0">&#40;</span>project.<span class="me1">name</span><span class="br0">&#41;</span><br />
&nbsp; <span class="kw1">if</span> name =~ /^\d\d\.\d\d.\d\d\d\d$/<br />
&nbsp; &nbsp; day = name<span class="br0">&#91;</span><span class="nu0">0</span>, <span class="nu0">2</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; month = name<span class="br0">&#91;</span><span class="nu0">3</span>, <span class="nu0">2</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; year = name<span class="br0">&#91;</span><span class="nu0">6</span>, <span class="nu0">4</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; app.<span class="me1">projects</span><span class="br0">&#91;</span>name<span class="br0">&#93;</span>.<span class="me1">name</span>.<span class="me1">set</span><span class="br0">&#40;</span>year+<span class="st0">&quot;_&quot;</span>+month+<span class="st0">&quot;_&quot;</span>+day<span class="br0">&#41;</span><br />
&nbsp; <span class="kw1">end</span><br />
<span class="br0">&#125;</span></div>
]]></content:encoded>
			<wfw:commentRss>http://devgrind.com/2008/08/01/scripting-the-night-away/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

