<?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>minding the gaps</title>
	<atom:link href="http://www.mindingthegaps.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mindingthegaps.com/blog</link>
	<description>The discovery, acceptance &#38; management of life&#039;s gaps</description>
	<lastBuildDate>Sun, 01 Apr 2012 03:58:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Running AppleScript from the Command Line</title>
		<link>http://www.mindingthegaps.com/blog/2012/03/31/running-applescript-from-the-command-line/</link>
		<comments>http://www.mindingthegaps.com/blog/2012/03/31/running-applescript-from-the-command-line/#comments</comments>
		<pubDate>Sat, 31 Mar 2012 23:32:25 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescrunix]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3550</guid>
		<description><![CDATA[Running AppleScript, and thus AppleScrunix, from the command line is quite simple. The command is osascript, see the osascript(1) Mac OS X Manual Page for more information. Open the application &#8220;Terminal&#8221; and type &#8220;osascript&#8221; followed by a space at the prompt ($). Next type the full path to the script or simply drag the script [...]]]></description>
			<content:encoded><![CDATA[<p>Running AppleScript, and thus AppleScrunix, from the command line is quite simple. The command is osascript, see the <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/osascript.1.html" title="osascript man page" target="_blank">osascript(1) Mac OS X Manual Page</a> for more information. Open the application &#8220;Terminal&#8221; and type &#8220;osascript&#8221; followed by a space at the prompt ($). Next type the full path to the script or simply drag the script icon onto the terminal window and let terminal insert the path. The final command should look like below.</p>
<p><code><br />
$ osascript /path/to/script.scpt<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2012/03/31/running-applescript-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript &#124; AppleScrunix – Syncing Two Folders [Directories]</title>
		<link>http://www.mindingthegaps.com/blog/2012/02/27/applescript-applescrunix-syncing-two-folders-directories/</link>
		<comments>http://www.mindingthegaps.com/blog/2012/02/27/applescript-applescrunix-syncing-two-folders-directories/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 21:42:21 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescrunix]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[folders]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[syncing directories]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3458</guid>
		<description><![CDATA[In this AppleScrunix sample we combine AppleScripts ability to easily add user interaction in selection of a folder/directory, with the power of the Unix command rsync. rsync is a highly versatile and powerful tool. Spend some time reviewing the man page for rsync and you will see what I mean. The following snippet is ready [...]]]></description>
			<content:encoded><![CDATA[<p>In this <strong>AppleScrunix</strong> sample we combine <strong>AppleScripts</strong> ability to easily add user interaction in selection of a folder/directory, with the power of the Unix command <strong>rsync</strong>. <strong>rsync</strong> is a highly versatile and powerful tool. Spend some time reviewing the <a title="rsync man page" href="https://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man1/rsync.1.html" target="_blank">man page for rsync</a> and you will see what I mean.</p>
<p>The following snippet is ready to run. Just copy and paste into AppleScript Editor:<br />
<code><!-- Applescript --></code></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;"><span style="font-weight: bold; color: #000000;">set</span> <span style="color: #4f7f00;">sDir</span> <span style="font-weight: bold; color: #000000;">to</span> <span style="color: #6b04c3;">POSIX path</span><span style="color: #0015a0;"> <span style="font-weight: bold; color: #000000;">of</span> (<span style="font-weight: bold; color: #0015a0;">choose folder</span> <span style="color: #0015a0;">with prompt</span> <span style="color: #000000;">&quot;Select source&quot;)</span></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;"><span style="font-weight: bold; color: #000000;">set</span> <span style="color: #4f7f00;">dDir</span> <span style="font-weight: bold; color: #000000;">to</span> <span style="color: #6b04c3;">POSIX path</span><span style="color: #0015a0;"> <span style="font-weight: bold; color: #000000;">of</span> (<span style="font-weight: bold; color: #0015a0;">choose folder</span> <span style="color: #0015a0;">with prompt</span> <span style="color: #000000;">&quot;Select destination&quot;)</span></span></p>
<p></br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;"><span style="font-weight: bold; color: #0015a0;">do shell script</span> <span style="color: #000000;">&quot;rsync -zrtpl &#8211;stats &#8211;delete -e ssh &quot; &#038;</span> <span style="color: #6b04c3;">quoted form</span> <span style="font-weight: bold; color: #000000;">of</span> <span style="color: #000000;">(</span><span style="color: #4f7f00;">sDir</span><span style="color: #000000;">) &#038; &quot; &quot; &#038;</span> <span style="color: #6b04c3;">quoted form</span> <span style="font-weight: bold; color: #000000;">of</span> <span style="color: #000000;">(</span><span style="color: #4f7f00;">dDir</span><span style="color: #000000;">)</span></p>
</div>
<p></br>I am not going to explain anything in this post about the script&#8217;s construction, syntax or arguments. I plan to delve into these matters in subsequent posts. However, if you have specific questions, I will be happy to answer them.</p>
<hr />
For this exercise use two folders. The first one is your source directory/folder and contains the files and folders you want synchronized. The second one is empty. If you run the script in the editor you will get feedback like below in the result box. Run the script&#8230; <strong>First Run</strong> shows the number of files transferred when syncing the first time. Run it again&#8230; <strong>Second Run</strong> shows the number of files transferred when syncing the second time. Note that it is zero. rsync compared the two folders and saw there were no changes so no files needed to be updated.</p>
<hr />
<strong>First Run:</strong><br />
Number of files: 168<br />
Number of files transferred: 139<br />
Total file size: 48894704 bytes<br />
Total transferred file size: 48894654 bytes<br />
Literal data: 48894654 bytes<br />
Matched data: 0 bytes<br />
File list size: 3470<br />
File list generation time: 0.001 seconds<br />
File list transfer time: 0.000 seconds<br />
Total bytes sent: 48910444<br />
Total bytes received: 3252</p>
<p>sent 48910444 bytes received 3252 bytes 32609130.67 bytes/sec<br />
total size is 48894704 speedup is 1.00</p>
<hr />
<strong>Second Run:</strong><br />
Number of files: 168<br />
Number of files transferred: 0<br />
Total file size: 48894704 bytes<br />
Total transferred file size: 0 bytes<br />
Literal data: 0 bytes<br />
Matched data: 0 bytes<br />
File list size: 3470<br />
File list generation time: 0.001 seconds<br />
File list transfer time: 0.000 seconds<br />
Total bytes sent: 3486<br />
Total bytes received: 20</p>
<p>sent 3486 bytes received 20 bytes 7012.00 bytes/sec<br />
total size is 48894704 speedup is 13946.01</p>
<hr />
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2012/02/27/applescript-applescrunix-syncing-two-folders-directories/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Dance with ThunderBolt – Update 2</title>
		<link>http://www.mindingthegaps.com/blog/2011/12/31/a-dance-with-thunderbolt-%e2%80%93-update-2/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/12/31/a-dance-with-thunderbolt-%e2%80%93-update-2/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 01:59:11 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[LaCie]]></category>
		<category><![CDATA[Thunderbolt]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3451</guid>
		<description><![CDATA[At the stroke of midnight tonight, I will have completed 3 full months of testing of a real-time web tracking solution that depends heavily on ThunderBolt technology. Though I continue to be plagued with drive issues, a single drive has been fast enough to deal with the current read/write requirements.]]></description>
			<content:encoded><![CDATA[<p>At the stroke of midnight tonight, I will have completed 3 full months of testing of a real-time web tracking solution that depends heavily on ThunderBolt technology. Though I continue to be plagued with drive issues, a single drive has been fast enough to deal with the current read/write requirements. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/12/31/a-dance-with-thunderbolt-%e2%80%93-update-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Dance with ThunderBolt &#8211; Update</title>
		<link>http://www.mindingthegaps.com/blog/2011/11/30/a-dance-with-thunderbolt-update/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/11/30/a-dance-with-thunderbolt-update/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 04:47:15 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[LaCie]]></category>
		<category><![CDATA[Thunderbolt]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3438</guid>
		<description><![CDATA[Initial testing of the LaCie ThunderBolt drives on a MacMini Server looked pretty good&#8230; That is after I returned the fist MacMini Server that had a dead Thunderbolt port. More in the next day or so&#8230;.]]></description>
			<content:encoded><![CDATA[<p>Initial testing of the LaCie ThunderBolt drives on a MacMini Server looked pretty good&#8230; That is after I returned the fist MacMini Server that had a dead Thunderbolt port. More in the next day or so&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/11/30/a-dance-with-thunderbolt-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Dance with ThunderBolt</title>
		<link>http://www.mindingthegaps.com/blog/2011/10/31/a-dance-with-thunderbolt/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/10/31/a-dance-with-thunderbolt/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 01:59:05 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Hard Drive]]></category>
		<category><![CDATA[LaCie]]></category>
		<category><![CDATA[Thunderbolt]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3411</guid>
		<description><![CDATA[I began testing Lacie&#8217;s Big Little Disk ThunderBolt drives this last week. Lacie makes some pretty big claims for these little guys and I am determined to find out if they measure up. I have several coding projects in the hopper that will definitely put them to the test. More soon.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mindingthegaps.com/blog/wp-content/uploads/2011/10/LBD-ThunderBolt-Disk.png"><img src="http://www.mindingthegaps.com/blog/wp-content/uploads/2011/10/LBD-ThunderBolt-Disk-150x150.png" alt="Lacie Little Big Disk - ThunderBolt" title="LBD ThunderBolt Disk" width="150" height="150" class="alignleft size-thumbnail wp-image-3412" /></a>I began testing <a href="http://www.lacie.com/us/products/product.htm?id=10549">Lacie&#8217;s Big Little Disk ThunderBolt</a> drives this last week. Lacie makes some pretty big claims for these little guys and I am determined to find out if they measure up. I have several coding projects in the hopper that will definitely put them to the test. <strong>More soon</strong>.<a href="http://www.mindingthegaps.com/blog/wp-content/uploads/2011/10/LBD-ThunderBolt-Performance-e1320112573871.png"><img src="http://www.mindingthegaps.com/blog/wp-content/uploads/2011/10/LBD-ThunderBolt-Performance-e1320112573871.png" alt="Lacie Little Big Disk - ThunderBolt - Performance Chart" title="LBD ThunderBolt Performance" width="523" height="249" class="aligncenter size-full wp-image-3413" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/10/31/a-dance-with-thunderbolt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPirate &#8211; The Bucs Go iPad</title>
		<link>http://www.mindingthegaps.com/blog/2011/08/31/ipirate-the-bucs-go-ipad/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/08/31/ipirate-the-bucs-go-ipad/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 21:58:14 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[gaps]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[Teams]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Bucs]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[playbook]]></category>
		<category><![CDATA[Tampa Bay Buccaneers]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[use case]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3370</guid>
		<description><![CDATA[A month before the launch of Apple&#8217;s original iPad, I predicted that sports teams would replace their playbooks with the tablet computer, see Countdown to iPad – Playbook (Use Case 18). Recently the Tampa Bay Buccaneers bought iPads for their players to do just that, see Tampa Bay Buccaneers buy each player an iPad to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.mindingthegaps.com/blog/wp-content/uploads/2010/02/coach-150x150.jpg" alt="" title="coach" width="150" height="150" class="alignleft size-thumbnail wp-image-1032" /></p>
<p>A month before the <a href="http://news.cnet.com/8301-13579_3-20001601-37.html">launch of Apple&#8217;s original iPad</a>, I predicted that sports teams would replace their playbooks with the tablet computer, see <a href="http://www.mindingthegaps.com/blog/2010/03/04/countdown-to-ipad-–-playbook-use-case-18/?preview=true&#038;preview_id=1034&#038;preview_nonce=2a417102de">Countdown to iPad – Playbook</a> (Use Case 18). </p>
<p>Recently the Tampa Bay Buccaneers bought iPads for their players to do just that, see <a href="http://www.tampabay.com/sports/football/bucs/article1187879.ece">Tampa Bay Buccaneers buy each player an iPad to hold playbook, videos</a>.</p>
<p>As further predicted, the Buccaneer coaches and players not only watch plays on the iPads, but if the devices are ever lost, &#8220;You&#8217;ve got a way to wipe (everything) off with the push of a button,&#8221; according to Tampa Bay Bucs Coach, Raheem Morris. ~ quote from <a href="http://www.tampabay.com/">tampabay.com</a> article. </p>
<p><strong>iPad:</strong> Team Player</p>
<hr />In the <strong>Countdown to iPad Series</strong> (early 2010), I presented possible use cases for the amazing device that had yet to be released into the wild. Now that iPads have been with us for more than a year, it&#8217;s interesting to see just how many predictions have come true.</p>
<hr />
<p>iPad &#8211; Copyright © 2010 Apple Inc. (<a href="http://www.apple.com">www.apple.com</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/08/31/ipirate-the-bucs-go-ipad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript &#124; AppleScrunix &#8211; Listing files in a folder</title>
		<link>http://www.mindingthegaps.com/blog/2011/07/26/applescript-applescrunix-listing-files-in-a-folder/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/07/26/applescript-applescrunix-listing-files-in-a-folder/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 23:09:08 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescrunix]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[listing files]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[title case]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3298</guid>
		<description><![CDATA[One of the most common uses for AppleScript, and thus AppleScrunix, is to process files in a folder/directory. In order to process them you must first list the files. Though I find the listing of a folder of files, just as easy using straight AppleScript as I do with AppleScrunix, I much prefer the variations [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most common uses for AppleScript, and thus AppleScrunix, is to process files in a folder/directory. In order to process them you must first list the files. Though I find the listing of a folder of files, just as easy using straight AppleScript as I do with AppleScrunix, I much prefer the variations of returned lists in AppleScrunix.</p>
<p>A simple file listing in AppleScript looks like:<br />
<code><!-- Applescript --></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0px;">
<span style="font-weight: bold; color: #000000;">tell</span><span> </span><span style="color: #0015a0;"><em>application</em></span><span> </span><span style="color: #000000;">"System Events"</span><span> </span><span style="font-weight: bold; color: #000000;">to set</span><span> </span><span style="color: #4f7f00;">fileList</span><span> </span><span style="font-weight: bold; color: #000000;">to</span><span> </span><span style="color: #6b04c3;">name</span><span> </span><span style="color: #0015a0;"><em>items</em></span><span> </span><span style="font-weight: bold; color: #000000;">in</span><span> </span><span style="color: #0015a0;"><em>folder</em></span><span> </span><span style="margin: 0.0px 0.0px 0.0px 20.0px; color: #000000;">"/Users/avail/Desktop/PDFs"</span></p>
</div>
<p><!-- Applescript end --></code><br />
<strong>Result:</strong> {&#8220;001_FILENAME.PDF&#8221;, &#8220;001_FILENAME.txt&#8221;, &#8220;002_FILENAME.PDF&#8221;, &#8220;003_FILENAME.PDF&#8221;, &#8220;004_FILENAME.PDF&#8221;, &#8220;010_FILENAME.PDF&#8221;, &#8220;011_FILENAME.PDF&#8221;, &#8220;016_FILENAME.PDF&#8221;}</p>
<p>The same example in AppleScrunix looks like:<br />
<code><!-- Applescript --></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0px;">
<span style="font-weight: bold; color: #000000;">set</span><span> </span><span style="color: #4f7f00;">fileList</span><span> </span><span style="font-weight: bold; color: #000000;">to</span><span> </span><span style="color: #0015a0;"><em>paragraphs</em></span><span> </span><span style="font-weight: bold; color: #000000;">of</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">(</span><span style="font-weight: bold; color: #0015a0;">do shell script</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">"ls /Users/avail/Desktop/PDFs/")</span></p>
</div>
<p><!-- Applescript end --></code><br />
<strong>Same Result:</strong> {&#8220;001_FILENAME.PDF&#8221;, &#8220;001_FILENAME.txt&#8221;, &#8220;002_FILENAME.PDF&#8221;, &#8220;003_FILENAME.PDF&#8221;, &#8220;004_FILENAME.PDF&#8221;, &#8220;010_FILENAME.PDF&#8221;, &#8220;011_FILENAME.PDF&#8221;, &#8220;016_FILENAME.PDF&#8221;}</p>
<p>If all I had gained was a slightly shorter line of code it wouldn&#8217;t be worth it. However, now that we have entered the world of AppleScrunix, we can leverage the power of unix commands with just a few additional characters.</p>
<p>Simply adding an asterisk to my command, I get a list of file paths and not just file names:<br />
<code><!-- Applescript --></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0px;">
<span style="font-weight: bold; color: #000000;">set</span><span> </span><span style="color: #4f7f00;">fileList</span><span> </span><span style="font-weight: bold; color: #000000;">to</span><span> </span><span style="color: #0015a0;"><em>paragraphs</em></span><span> </span><span style="font-weight: bold; color: #000000;">of</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">(</span><span style="font-weight: bold; color: #0015a0;">do shell script</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">"ls /Users/avail/Desktop/PDFs/*")</span></p>
</div>
<p><!-- Applescript end --></code><br />
<strong>Result:</strong> {&#8220;/Users/avail/Desktop/PDFs/001_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/001_FILENAME.txt&#8221;, &#8220;/Users/avail/Desktop/PDFs/002_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/003_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/004_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/010_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/011_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/016_FILENAME.PDF&#8221;}</p>
<p>What if I just want to list the pdf files and not the text (txt) files? By just adding &#8216;*PDF&#8217; I get the desired result:<br />
<code><!-- Applescript --></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0px;">
<span style="font-weight: bold; color: #000000;">set</span><span> </span><span style="color: #4f7f00;">fileList</span><span> </span><span style="font-weight: bold; color: #000000;">to</span><span> </span><span style="color: #0015a0;"><em>paragraphs</em></span><span> </span><span style="font-weight: bold; color: #000000;">of</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">(</span><span style="font-weight: bold; color: #0015a0;">do shell script</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">"ls /Users/avail/Desktop/PDFs/*PDF")</span></p>
</div>
<p><!-- Applescript end --></code><br />
<strong>Result:</strong> {&#8220;/Users/avail/Desktop/PDFs/001_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/002_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/003_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/004_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/010_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/011_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/016_FILENAME.PDF&#8221;}</p>
<p>Or, what if I just want to list the files numbered between 010 and 019? By just adding &#8217;01*&#8217; I get the desired list of files:<br />
<code><!-- Applescript --></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0px;">
<span style="font-weight: bold; color: #000000;">set</span><span> </span><span style="color: #4f7f00;">fileList</span><span> </span><span style="font-weight: bold; color: #000000;">to</span><span> </span><span style="color: #0015a0;"><em>paragraphs</em></span><span> </span><span style="font-weight: bold; color: #000000;">of</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">(</span><span style="font-weight: bold; color: #0015a0;">do shell script</span><span> </span><span style="margin: 0.0px 0.0px 0.0px 0.0px; color: #000000;">"ls /Users/avail/Desktop/PDFs/01*")</span></p>
</div>
<p><!-- Applescript end --></code><br />
<strong>Result:</strong> {&#8220;/Users/avail/Desktop/PDFs/010_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/011_FILENAME.PDF&#8221;, &#8220;/Users/avail/Desktop/PDFs/016_FILENAME.PDF&#8221;}</p>
<p>Study the man page for &#8216;ls&#8217; and you will find a treasure trove of small command modifications that will make a big difference in your solutions.</p>
<hr />
<strong>AppleScript / AppleScrunix Examples</strong> &#8211; using the do shell script command in AppleScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/07/26/applescript-applescrunix-listing-files-in-a-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Applescript &amp; Python To Set Title Case (AppleScrunix)</title>
		<link>http://www.mindingthegaps.com/blog/2011/06/30/using-applescript-python-to-set-title-case-applescrunix/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/06/30/using-applescript-python-to-set-title-case-applescrunix/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 13:02:16 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescrunix]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lowercase]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[title case]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[uppercase]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3214</guid>
		<description><![CDATA[One way in which Apple has turned the Mac into the most powerful scripting/automation platform on the planet has been to provide a litany of scriptable languages as part of the standard install. Just some of the languages you will find in Mac OS X are JavaScript, Ruby, Python, and of course AppleScript. I refer [...]]]></description>
			<content:encoded><![CDATA[<p>One way in which Apple has turned the <strong>Mac</strong> into <strong>the most powerful scripting/automation platform on the planet</strong> has been to provide a litany of scriptable languages as part of the standard install. Just some of the languages you will find in <strong>Mac OS X</strong> are <strong>JavaScript</strong>, <strong>Ruby</strong>, <strong>Python</strong>, and of course <strong>AppleScript</strong>. I refer to the <strong>mashing</strong> all these languages <strong>together as AppleScrunix</strong>.</p>
<p>Each of the languages has strengths and weaknesses. By bringing them all together on a single platform, and making it easy for them to be used together, <strong>Apple has put an amazing amount of automation power in our hands</strong>.</p>
<p>As shown in previous posts <strong>AppleScrunix allows me to work primarily in AppleScript and draw from other languages</strong> when my scripting language of choice comes up a bit short.</p>
<p>I often run across the need to do &#8216;simple&#8217; title case conversion. &#8216;Simple&#8217; meaning every word in the title has its first letter capitalized and all remaining letters are lowercase. Though this is possible <strong>using only standard AppleScript</strong>, the project quickly <strong>becomes complicated</strong> and ends up <strong>running slower than it needs to</strong>.</p>
<p>If you are interested in solving this problem just using AppleScript, you can get much of the code you need from my previous post, <a href="http://www.mindingthegaps.com/blog/2011/05/26/applescript-converting-uppercase-lowercase-applescrunix-style/">Applescript – Converting Uppercase &amp; Lowercase (AppleScrunix Style)</a>.</p>
<p>Or you can do it using <strong>AppleScrunix and just 2 lines of code</strong>. I have messed up the title ahead of time to make it more interesting&#8230; <strong>thIs is thE stORY of a GIRL</strong> becomes <strong>This Is The Story Of A Girl</strong>.</p>
<p>Begin Script&#8230;<br />
<code><!-- Applescript --></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight: bold; color: #000000;">set</span><span> </span><span style="color: #4f7f00;">myTitle</span><span> </span><span style="font-weight: bold; color: #000000;">to</span><span> </span><span style="color: #000000&quot;;">"thIs is thE stORY of a GIRL"</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight: bold; color: #0015a0;">do shell script</span><span> </span><span style="color: #000000&quot;;">"python -c \"print " &amp;</span><span> </span><span style="color: #6b04c3;">quoted form</span><span> </span><span style="font-weight: bold; color: #000000;">of</span><span> </span><span style="color: #000000&quot;;">(</span><span style="color: #4f7f00;">myTitle</span><span style="color: #000000&quot;;">) &amp; ".title()\""</span></p>
</div>
<p><!-- Applescript end --></code><br />
&#8230;End Script</p>
<p>Result: &#8220;This Is The Story Of A Girl&#8221;</p>
<hr />
<strong>AppleScript / AppleScrunix Examples</strong> &#8211; using the do shell script command in AppleScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/06/30/using-applescript-python-to-set-title-case-applescrunix/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Applescript &#8211; Converting Uppercase &amp; Lowercase (AppleScrunix Style)</title>
		<link>http://www.mindingthegaps.com/blog/2011/05/26/applescript-converting-uppercase-lowercase-applescrunix-style/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/05/26/applescript-converting-uppercase-lowercase-applescrunix-style/#comments</comments>
		<pubDate>Fri, 27 May 2011 00:23:44 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescrunix]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[lowercase]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[uppercase]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3110</guid>
		<description><![CDATA[As there are no built-in routines for changing the case of characters in AppleScript, the coder is required to add their own handlers. The following script (See credits below) shows one way to use AppleScript to change the names of files in a folder from lowercase to uppercase &#038; vise-versa. Begin Script&#8230; tell application "Finder" [...]]]></description>
			<content:encoded><![CDATA[<p>As there are no built-in routines for changing the case of characters in <strong>AppleScript</strong>, the coder is required to add their own handlers. The following script (See credits below) shows one way to use <strong>AppleScript</strong> to change the names of files in a folder from lowercase to uppercase &#038; vise-versa.</p>
<p>Begin Script&#8230;<br />
<code><!-- Applescript --></p>
<div id="Applescript">
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">tell</span> <span style="color:#000000"> </span> <span style="color:#0000FF">application</span> <span style="color:#000000"> "Finder" </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">source_folder</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#0015A0">choose folder</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">tell</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">me</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#0000FF">activate</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#0015A0">display dialog</span> <span style="color:#000000"> "Change case to:" </span> <span style="color:#0015A0">buttons</span> <span style="color:#000000"> {"Cancel", "UPPER", "lower"}<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">button_pressed</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4314A0">button returned</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#6B04C3">result</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">tell</span> <span style="color:#000000"> </span> <span style="color:#0000FF">application</span> <span style="color:#000000"> "Finder"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">repeat</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">with</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">this_item</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">in</span> <span style="color:#000000"> </span> <span style="color:#6B04C3">entire contents</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">source_folder</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">current_name</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#6B04C3">name</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">this_item</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">as</span> <span style="color:#000000"> </span> <span style="color:#0000FF">text</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">button_pressed</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">is</span> <span style="color:#000000"> "lower" </span> <span style="font-weight:bold;color:#000000">then</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 60px;"><span style="color:#000000">			</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#6B04C3">name</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">this_item</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">my</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">change_case</span> <span style="color:#000000">(</span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">current_name</span> <span style="color:#000000">, "lower")<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">else</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 60px;"><span style="color:#000000">			</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#6B04C3">name</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">this_item</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">my</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">change_case</span> <span style="color:#000000">(</span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">current_name</span> <span style="color:#000000">, "upper")<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">repeat</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">tell</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#0015A0">display dialog</span> <span style="color:#000000"> "Process complete"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="color:#000000"><br />
</span> </p>
<p>-- AppleScript 'change_case' handler</p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">on</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">change_case</span> <span style="color:#000000">(</span> <span style="color:#4F7F00">this_text</span> <span style="color:#000000">, </span> <span style="color:#4F7F00">this_case</span> <span style="color:#000000">)<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">this_case</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">is</span> <span style="color:#000000"> "lower" </span> <span style="font-weight:bold;color:#000000">then</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">comparison_string</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> "ABCDEFGHIJKLMNOPQRSTUVWXYZ"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">source_string</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> "abcdefghijklmnopqrstuvwxyz"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">else</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">comparison_string</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> "abcdefghijklmnopqrstuvwxyz"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">source_string</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> "ABCDEFGHIJKLMNOPQRSTUVWXYZ"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> ""<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">repeat</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">with</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">thisChar</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">in</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">this_text</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">x</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#0015A0">offset</span> <span style="color:#000000"> </span> <span style="color:#0015A0">of</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">thisChar</span> <span style="color:#000000"> </span> <span style="color:#0015A0">in</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">comparison_string</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">x</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">is</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">not</span> <span style="color:#000000"> 0 </span> <span style="font-weight:bold;color:#000000">then</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 60px;"><span style="color:#000000">			</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> (</span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"> &#038; </span> <span style="color:#0000FF">character</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">x</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">source_string</span> <span style="color:#000000">) </span> <span style="font-weight:bold;color:#000000">as</span> <span style="color:#000000"> </span> <span style="color:#0000FF">string</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">else</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 60px;"><span style="color:#000000">			</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> (</span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"> &#038; </span> <span style="color:#4F7F00">thisChar</span> <span style="color:#000000">) </span> <span style="font-weight:bold;color:#000000">as</span> <span style="color:#000000"> </span> <span style="color:#0000FF">string</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">repeat</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">return</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">change_case</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"></div>
<p><!-- Applescript end --></code><br />
&#8230;End Script</p>
<p>The following handler &#8216;change_case&#8217; was rewritten using <strong>AppleScrunix</strong>. Not only is there less code, but the script runs faster. Replace the <strong>AppleScript</strong> version of the handler in the above script with the unix based handler below.</p>
<p>Begin Handler&#8230;<br />
<code><!-- Applescript --></p>
<div id="Applescript">
-- AppleScrunix 'change_case' handler</p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">on</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">change_case</span> <span style="color:#000000">(</span> <span style="color:#4F7F00">this_text</span> <span style="color:#000000">, </span> <span style="color:#4F7F00">this_case</span> <span style="color:#000000">)<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">this_case</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">is</span> <span style="color:#000000"> "lower" </span> <span style="font-weight:bold;color:#000000">then</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#0015A0">do shell script</span> <span style="color:#000000"> "echo " &#038; </span> <span style="color:#6B04C3">quoted form</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> (</span> <span style="color:#4F7F00">this_text</span> <span style="color:#000000">) &#038; " | tr A-Z a-z"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">else</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 40px;"><span style="color:#000000">		</span> <span style="font-weight:bold;color:#000000">set</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">to</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#0015A0">do shell script</span> <span style="color:#000000"> "echo " &#038; </span> <span style="color:#6B04C3">quoted form</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">of</span> <span style="color:#000000"> (</span> <span style="color:#4F7F00">this_text</span> <span style="color:#000000">) &#038; " | tr a-z A-Z"<br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">if</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 20px;"><span style="color:#000000">	</span> <span style="font-weight:bold;color:#000000">return</span> <span style="color:#000000"> </span> <span style="font-weight:bold;color:#000000">the</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">new_text</span> <span style="color:#000000"><br />
</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"><span style="font-weight:bold;color:#000000">end</span> <span style="color:#000000"> </span> <span style="color:#4F7F00">change_case</span> </p>
<p style="margin: 0.0px 0.0px 0.0px 0px;"></div>
<p><!-- Applescript end --></code><br />
&#8230;End Handler</p>
<p>The above AppleScrunix example uses shell command &#8216;tr&#8217; to translate uppercase to lowercase, etc. Refer to the <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/tr.1.html"><strong>tr Mac OS X Man (Manual) Page</strong></a> for other uses.</p>
<hr />
<strong>Credits:</strong> I picked up the initial example script almost verbatim from <a href="https://discussions.apple.com/message/11452277">Apple Support Communities</a>. It was posted by a user I only know as V.K., on April 16, 2009 @ 10:13 am. ~Thanks VK!</p>
<hr />
<strong>AppleScript / AppleScrunix Examples</strong> &#8211; using the do shell script command in AppleScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/05/26/applescript-converting-uppercase-lowercase-applescrunix-style/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sorting with AppleScript (AppleScrunix Style)</title>
		<link>http://www.mindingthegaps.com/blog/2011/04/29/sorting-with-applescript-applescrunix-style/</link>
		<comments>http://www.mindingthegaps.com/blog/2011/04/29/sorting-with-applescript-applescrunix-style/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 20:50:03 +0000</pubDate>
		<dc:creator>Russ Leseberg</dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[gaps]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescrunix]]></category>
		<category><![CDATA[bubble sort]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.mindingthegaps.com/blog/?p=3063</guid>
		<description><![CDATA[As there is no built-in sort function in AppleScript you have to create your own. A common way of sorting lists is to use the repeat function&#8230; cycling through the list comparing items as you progress.  One of the more efficient approaches is a bubble sort. You can find an excellent example in Lesson 18, [...]]]></description>
			<content:encoded><![CDATA[<p>As there is no built-in sort function in AppleScript you have to create your own. A common way of sorting lists is to use the repeat function&#8230; cycling through the list comparing items as you progress.  One of the more efficient approaches is a bubble sort. You can find an excellent example in Lesson 18, &#8220;Working with Lists and Records&#8221; in <strong>Sal Saghoian&#8217;s</strong> book, <a href="http://www.amazon.com/s/?tag=mindingthegap-20&amp;creative=392013&amp;campaign=212361&amp;link_code=wsw&amp;_encoding=UTF-8&amp;search-alias=aps&amp;field-keywords=applescript+123&amp;Submit.x=0&amp;Submit.y=0&amp;Submit=Go">AppleScript 1-2-3</a>.</p>
<p>This <strong>AppleScript</strong> bubble sort was taken in part from Sal&#8217;s book:</p>
<p><code></p>
<p style="margin: 0.0px 0.0px 0.0px 0px; font: 12.0px Verdana;"><strong>set</strong> <span style="color: #528e12;">fruit</span> <strong>to</strong> {"pears", "bananas", "apples", "grapes", "watermelon", "pineapple"}</p>
<p style="margin: 0.0px 0.0px 0.0px 0px; font: 12.0px Verdana; color: #528e12;"><span style="color: #000000;"><strong>set</strong> </span>last_swap_position<span style="color: #000000;"> <strong>to</strong> </span><span style="color: #8039d9;">length</span><span style="color: #000000;"> <strong>of</strong> </span>fruit</p>
<p style="margin: 0.0px 0.0px 0.0px 0px; font: 12.0px Verdana; color: #528e12;"><span style="color: #000000;"><strong>repeat</strong> <strong>while</strong> </span>last_swap_position<span style="color: #000000;"> &gt; 0</span></p>
<p style="margin: 0.0px 0.0px 0.0px 20px; font: 12.0px Verdana; color: #528e12;"><span style="color: #000000;"><span style="white-space: pre;"> </span><strong>set</strong> </span>comparisons_needed<span style="color: #000000;"> <strong>to</strong> </span>last_swap_position<span style="color: #000000;"> - 1</span></p>
<p style="margin: 0.0px 0.0px 0.0px 20px; font: 12.0px Verdana; color: #528e12;"><span style="color: #000000;"><span style="white-space: pre;"> </span><strong>set</strong> </span>last_swap_position<span style="color: #000000;"> <strong>to</strong> 0</span></p>
<p style="margin: 0.0px 0.0px 0.0px 20px; font: 12.0px Verdana;"><span style="white-space: pre;"> </span><strong>repeat</strong> <strong>with</strong> <span style="color: #528e12;">i</span> <strong>from</strong> 1 <strong>to</strong> <span style="color: #528e12;">comparisons_needed</span></p>
<p style="margin: 0.0px 0.0px 0.0px 40px; font: 12.0px Verdana;"><span style="white-space: pre;"> </span><strong>if</strong> <span style="color: #1440fc;"><em>item</em></span> <span style="color: #528e12;">i</span> <strong>of</strong> <span style="color: #528e12;">fruit</span> &gt; <span style="color: #1440fc;"><em>item</em></span> (<span style="color: #528e12;">i</span> + 1) <strong>of</strong> <span style="color: #528e12;">fruit</span> <strong>then</strong></p>
<p style="margin: 0.0px 0.0px 0.0px 60px; font: 12.0px Verdana;"><span style="white-space: pre;"> </span><strong>set</strong> <span style="color: #528e12;">swap_item</span> <strong>to</strong> <span style="color: #1440fc;"><em>item</em></span> <span style="color: #528e12;">i</span> <strong>of</strong> <span style="color: #528e12;">fruit</span></p>
<p style="margin: 0.0px 0.0px 0.0px 60px; font: 12.0px Verdana;"><span style="white-space: pre;"> </span><strong>set</strong> <span style="color: #1440fc;"><em>item</em></span> <span style="color: #528e12;">i</span> <strong>of</strong> <span style="color: #528e12;">fruit</span> <strong>to</strong> <span style="color: #1440fc;"><em>item</em></span> (<span style="color: #528e12;">i</span> + 1) <strong>of</strong> <span style="color: #528e12;">fruit</span></p>
<p style="margin: 0.0px 0.0px 0.0px 60px; font: 12.0px Verdana;"><span style="white-space: pre;"> </span><strong>set</strong> <span style="color: #1440fc;"><em>item</em></span> (<span style="color: #528e12;">i</span> + 1) <strong>of</strong> <span style="color: #528e12;">fruit</span> <strong>to</strong> <span style="color: #528e12;">swap_item</span></p>
<p style="margin: 0.0px 0.0px 0.0px 60px; font: 12.0px Verdana; color: #528e12;"><span style="color: #000000;"><span style="white-space: pre;"> </span><strong>set</strong> </span>last_swap_position<span style="color: #000000;"> <strong>to</strong> </span>i</p>
<p style="margin: 0.0px 0.0px 0.0px 40px; font: 12.0px Verdana;"><span style="white-space: pre;"> </span><strong>end</strong> <strong>if</strong></p>
<p style="margin: 0.0px 0.0px 0.0px 20px; font: 12.0px Verdana;"><span style="white-space: pre;"> </span><strong>end</strong> <strong>repeat</strong></p>
<p style="margin: 0.0px 0.0px 0.0px 0px; font: 12.0px Verdana;"><strong>end</strong> <strong>repeat</strong></p>
<p style="margin: 0.0px 0.0px 0.0px 0px; font: 12.0px Verdana;"><strong>return</strong> <span style="color: #528e12;">fruit</span></p>
<p style="margin: 0.0px 0.0px 0.0px 41.6px; text-indent: -41.6px; font: 12.0px Verdana;"><span style="color: #528e12;"> </span><span style="font-family: Times; font-size: small;">= {"apples", "bananas", "grapes", "pears", "pineapple", "watermelon"}</span></p>
<p></code></p>
<p>Using <strong>AppleScrunix</strong> you can sort the same list using a shell script sort command:<br />
<code> </code></p>
<p><code> </code></p>
<p><code></p>
<p style="margin: 0.0px 0.0px 0.0px 41.6px; text-indent: -41.6px; font: 12.0px Verdana;"><strong>set</strong> <span style="color: #528e12;">fruit</span> <strong>to</strong> {"pears", "bananas", "apples", "grapes", "watermelon", "pineapple"}</p>
<p style="margin: 0.0px 0.0px 0.0px 41.6px; text-indent: -41.6px; font: 12.0px Verdana; color: #8039d9;"><span style="color: #000000;"><strong>set</strong> </span>text item delimiters<span style="color: #000000;"> <strong>to</strong> {</span><span style="color: #0c37bc;"><strong>ASCII character</strong></span><span style="color: #000000;"> 10}</span></p>
<p style="margin: 0.0px 0.0px 0.0px 41.6px; text-indent: -41.6px; font: 12.0px Verdana;"><strong>set</strong> <span style="color: #528e12;">fruit</span> <strong>to</strong> <span style="color: #528e12;">fruit</span> <strong>as</strong> <span style="color: #1440fc;"><em>string</em></span></p>
<p style="margin: 0.0px 0.0px 0.0px 41.6px; text-indent: -41.6px; font: 12.0px Verdana;"><strong>set</strong> <span style="color: #528e12;">fruit</span> <strong>to</strong> <span style="color: #1440fc;"><em>paragraphs</em></span> <strong>of</strong> (<span style="color: #0c37bc;"><strong>do shell script</strong></span> "echo " &amp; <span style="color: #8039d9;">quoted form</span> <strong>of</strong> (<span style="color: #528e12;">fruit</span>) &amp; " | sort -f")</p>
<p style="margin: 0.0px 0.0px 0.0px 41.6px; text-indent: -41.6px; font: 12.0px Verdana; color: #8039d9;"><span style="color: #000000;"><strong>set</strong> </span>text item delimiters<span style="color: #000000;"> <strong>to</strong> ""</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0px; font: 12.0px Verdana;"><strong>return</strong> <span style="color: #528e12;">fruit</span></p>
<p style="margin: 0.0px 0.0px 0.0px 41.6px; text-indent: -41.6px; font: 12.0px Verdana;"><span style="color: #528e12;"> </span><span style="font-family: Times; font-size: small;">= {"apples", "bananas", "grapes", "pears", "pineapple", "watermelon"}</span></p>
<p></code></p>
<p>Though it doesn&#8217;t save much coding, it executes faster, especially as the lists get longer. Using sort, via shell, also allows for files/lists to be sorted without having to open them. I will cover that in a future post.</p>
<p>We will continue to delve deeper into <strong>AppleScript</strong> &amp; <strong>AppleScrunix</strong> in future posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindingthegaps.com/blog/2011/04/29/sorting-with-applescript-applescrunix-style/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

