<?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>Paper Jammed &#187; Workflow</title>
	<atom:link href="http://paperjammed.com/category/workflow/feed/" rel="self" type="application/rss+xml" />
	<link>http://paperjammed.com</link>
	<description>Has paper taken over your life?</description>
	<lastBuildDate>Fri, 06 May 2011 00:09:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Export iTunes Playlists to a non-iTunes World</title>
		<link>http://paperjammed.com/2011/03/01/export-itunes-playlists-to-a-non-itunes-world/</link>
		<comments>http://paperjammed.com/2011/03/01/export-itunes-playlists-to-a-non-itunes-world/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 01:42:50 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Geekery]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Files and Folders]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Media]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=1148</guid>
		<description><![CDATA[Do you want to automatically publish iTunes playlists to a non-iTunes music library? This free application will convert iTunes playlists to m3u files, transform paths to match your external master library, and then copy the playlists over the network. It will even ping a Squeezebox server to force a playlist refresh.]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-1165" title="iStock_000000260938XSmall" src="http://paperjammed.com/wp-content/uploads/2011/03/iStock_000000260938XSmall-300x225.jpg" alt="" width="300" height="225" />I freely admit my dislike for iTunes—it&#8217;s a black box where you toss your music, giving full control over your library to Apple.<br />
The problem is that sometimes you might want to manage your library in a way that Apple never intended, and then things become challenging. iPods, iPads, and iPhones pretty much force us to use iTunes, so why not figure out some way to lessen the pain?</p>
<p>I like the playlist tools that iTunes provides, and I find it very convenient to create Smart Playlists or to create Genius lists. However, I want to keep my Master Library of music elsewhere, far from iTunes. Wouldn&#8217;t it be great if I could share these playlists on my home network in a completely nondenominational format? Wouldn&#8217;t it be nice if my Squeezebox server would have those same playlists available? And wouldn&#8217;t it be spectacular if those playlists would magically appear on a network drive whenever the lists change in iTunes?</p>
<p>Read on for details on how I accomplished this and to download the free utility I wrote to handle this task.<span id="more-1148"></span></p>
<p><strong>The Problem To Be Solved</strong></p>
<p>In order to understand what this application does, you need to know what I was trying to accomplish.</p>
<p>I have a NAS drive on my network that contains my Master Library of mp3 files. The files on this drive are located under <strong>/media/music</strong>.</p>
<p>I have a <a href="http://en.wikipedia.org/wiki/Squeezebox_Server">Squeezebox server</a>, running on an Ubuntu machine. This server is used by Squeezebox devices to play music anywhere in my house. It holds a copy of the Master Library, located under <strong>/srv/squeezebox/music</strong></p>
<p>What I want: I want my Mac to magically push <a href="http://en.wikipedia.org/wiki/M3U">proper m3u playlists</a> to the Squeezebox server—the Squeezebox server understands m3u playlists.</p>
<p>What I don&#8217;t want: Squeezebox supports direct access to iTunes. But I don&#8217;t want to do this because I don&#8217;t want to have to run Squeezebox on my Mac. Why did I bother setting up a dedicated <em>server</em> if I have to keep my Mac running?</p>
<p>Why is this challenging: Even if I could point Squeezebox to the bare iTunes database file, all of the file paths are wrong. My master library might have a song at <strong>&#8230;/artist/album_name/disc 1/</strong>, while iTunes might put it at <strong>&#8230;/Artist/Album Name/</strong>, omitting the <strong>disc 1</strong> folder and reformatting names.</p>
<p><strong>My Solution</strong></p>
<p>I wrote a small command line application in Perl that supports the following:</p>
<ul>
<li>Paths to songs in Apple&#8217;s mysterious black box are converted to nice paths to the same songs in my golden Master Library.</li>
<li>Even if a song name changes or a folder path changes, the original master copy is found.</li>
<li>All playlists are generated in m3u format.</li>
<li>Smart playlists and Genius playlists are supported.</li>
<li>The generated playlists are automatically moved to either a local directory or a remote server, using <strong><a href="http://en.wikipedia.org/wiki/Secure_copy">scp</a></strong>.</li>
<li>Network shares are automatically mounted at beginning of process and unmounted at end of process.</li>
<li>You can provide a file path to be prepended to all playlist entries.</li>
<li>Exits early if the iTunes library has not changed since the last run.</li>
<li>Supports exclusion patterns in order to skip some playlists.</li>
<li>A local Squeezebox server can be automatically pinged to cause it to refresh playlists.</li>
</ul>
<p>Here is the <a title="plmapper man page" href="http://paperjammed.com/plmapper.html">full documentation</a> for the Playlist Mapper application.</p>
<p><img class="alignnone size-full wp-image-1157" title="20110301-squeezebox" src="http://paperjammed.com/wp-content/uploads/2011/03/20110301-squeezebox.png" alt="" width="550" height="471" /></p>
<p><strong>Basic Installation</strong></p>
<p>Please note that this is a command line program. Some day I might figure out how to make a pretty GUI installer for it, but for now you have to get your hands a little dirty in order to install and configure.</p>
<p>Download the application here: <a href="http://paperjammed.com/wp-content/uploads/2011/03/plmapper.zip">plmapper</a></p>
<p>This is a Perl script that uses many standard utilities already present in a Snow Leopard OS X installation. You should not need anything other than the <strong>plmapper</strong> file itself.</p>
<p>Unzip the file and place <strong>plmapper</strong> in your home directory.</p>
<p>Open a Terminal window and make the script executable:</p>
<pre>chmod u+x plmapper</pre>
<p>Read the man page for the application by doing this:</p>
<pre>./plmapper --man</pre>
<p>There are many command line arguments, but you don&#8217;t need to worry about most of them. Create a file called <strong>plmapper.config</strong> in your home directory and put any arguments you need in that file, as name-value pairs.</p>
<p>Example:</p>
<pre>itunes=/Users/Bozo/Music/iTunes Music Library.xml
dest=/Users/Bozo/Desktop
library=/Volumes/media/music</pre>
<p>Once you have added all of the configuration settings, go ahead and run it:</p>
<pre>./plmapper</pre>
<p>You should see plenty of status information go by as each playlist is processed.</p>
<p><strong>Making it Run Automatically</strong></p>
<p>There are better ways of doing this, but I&#8217;m a command-line commando, so I simply added the following <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/cron.8.html">cron</a></strong> entry (see <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/crontab.1.html">crontab</a></strong>):</p>
<pre>0 22 * * * /Users/Me/bin/plmapper &gt;/Users/Me/plmapper.log 2&gt;&amp;1</pre>
<p>This causes the plmapper program to run once daily at 10pm, logging output to a file called <strong>plmapper.log</strong> in my home directory.</p>
<p>Of course, this can be tweaked to taste; it doesn&#8217;t matter if you run it hourly since the app skips any heavy lifting once it sees that the iTunes library file hasn&#8217;t been touched.</p>
<p><strong>How It Works</strong></p>
<p>The application performs the following basic steps:</p>
<ul>
<li>Mounts network shares using <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/mount_smbfs.8.html">mount_smbfs</a></strong>.</li>
<li>All music files in the external non-iTunes Master Library are listed in an internal data structure, sorted by file size.<br />
This allows us to quickly find a &#8220;short list&#8221; of possible candidate files that match a given source file. This works because mp3 files have fairly random sizes.</li>
<li>The iTunes database XML file is processed using an XSLT transformation to generate a set of basic <strong>m3u</strong> playlist files. The <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/xsltproc.1.html">xsltproc</a></strong> command line utility is used to run the transformation.</li>
<li>All paths in the playlists are converted from escaped URI syntax (e.g. %20 for space) to regular UTF-8 characters.</li>
<li>Each path is resolved to a single music file (i.e. an mp3 file) in the Master Library.<br />
This is done by obtaining the size of the iTunes version of the file and then looking this up in the internal list created in the first step.</li>
<li>Once a short list of candidates is found, the first few thousand bytes of each file are compared until a match is found.The risks of choosing the wrong file are low: all that will happen is that a song might be switched in the playlist accidentally. As such, it isn&#8217;t worth scanning the full file to ensure they are exact matches.This algorithm works quite well, and can detect music files that have been renamed and moved around.</li>
</ul>
<ul>
<li>The playlist files are now converted from <strong>utf8mac</strong> to <strong>utf8</strong> using the <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/iconv.1.html">iconv</a></strong> command line utility.This process collapses wide UTF-8 characters, consisting of a letter plus an accent add-on, into their single-letter equivalents. This process is known as Unicode Normalization, and this tool uses <strong>Normalization form C</strong>: Compatibility decompisitiion followed by canonical composition.</li>
<li>Playlist files are now copied to a local or remote directory, either as direct file copy or via the <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/scp.1.html">scp</a></strong> utility.</li>
<li>Optionally, a special call is made to a specified Squeezebox server to tell the server to refresh all playlists.</li>
<li>Any mounted shares that were mounted by this process are unmounted via <strong><a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/diskutil.8.html">diskutil</a> unmount</strong>.</li>
</ul>
<p><strong>Limitations</strong></p>
<ul>
<li>Nested folders of playlists currently act funny. The lists will come over, but you may get two lists. You can use the exclude option to prevent this.</li>
<li>Songs with non-ASCII characters in the file name might not be recognized by all players. Squeezebox has a problem with many special characters—I tested this by adding songs like <strong>Águas de Março.mp3</strong> using Squeezebox&#8217;s own playlist editor, and when I reloaded the list the songs were not there. This is a bug in Squeezebox server.</li>
<li>Occasionally the file matching algorithm might pick the wrong song. In an effort to speed up processing, the program only looks at the first few thousand bytes of files when comparing. It isn&#8217;t a big deal if the wrong file is added to a playlist, is it?</li>
</ul>
<p><strong>Closing Thoughts</strong></p>
<p>As often happens, this program was written because I had an itch that needed to be scratched. Now that I went through all of the hassles, I hope others can benefit.</p>
<p>Through good fortune, I am working in a Macintosh environment. This means that all of the important tools were already present on my machine: <strong>perl</strong>, <strong>xsltproc</strong>; <strong>mount</strong>; <strong>iconv</strong>; <strong>scp</strong>; <strong>nc</strong>; and others. If I were writing this for a PC, I probably would have written the whole thing in Java—a more familiar language to me, but one that comes with its own configuration issues.</p>
<p>I plan on updating plmapper over time, and if anyone has suggestions, please let me know.</p>
<p>And if a Perl guru wants to tell me my Perl skillz are subpar, go right ahead—but be gentle, and let me know how to improve the app.</p>
<p>[Update]</p>
<p>Fixed a couple of bugs related to path and &#8220;qx&#8221; calls, thanks to Chris. Updated version <a href="http://paperjammed.com/wp-content/uploads/2011/03/plmapper.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2011/03/01/export-itunes-playlists-to-a-non-itunes-world/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Another fifty pictures scanned and ten thousand to go&#8230;where did I leave off?</title>
		<link>http://paperjammed.com/2011/02/19/another-fifty-pictures-scanned-and-ten-thousand-to-go-where-did-i-leave-off/</link>
		<comments>http://paperjammed.com/2011/02/19/another-fifty-pictures-scanned-and-ten-thousand-to-go-where-did-i-leave-off/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 04:12:41 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Scanning]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Photos]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=1135</guid>
		<description><![CDATA[I have tons of old photos that I am always in the process of scanning in. Some are pictures from childhood, others are from my time in the Navy, and still others are from family life before digital photography (somewhere around the end of 2000 I bought my first digital camera, a Canon G1). I [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-1136" title="iStock_000003028590XSmall" src="http://paperjammed.com/wp-content/uploads/2011/02/iStock_000003028590XSmall-300x201.jpg" alt="" width="180" height="121" />I have tons of old photos that I am always in the process of scanning in. Some are pictures from childhood, others are from my time in the Navy, and still others are from family life before digital photography (somewhere around the end of 2000 I bought my first digital camera, a Canon G1).</p>
<p>I have been struggling with making everything digital for years now, and there are stacks of photos and thick albums that remain uncharted territory. Every once in awhile I sit down and scan in an album.</p>
<p>Trouble is, unless you do the whole job at once, it&#8217;s pretty easy to lose track of where you have already been. And if that&#8217;s not bad enough, we always bought double prints—they didn&#8217;t cost much more, and we could give some away. Now how do I know if I have scanned the long-lost twins of some photos that are already on my computer? That&#8217;s a problem for another day.</p>
<p>Here&#8217;s how I make sure I don&#8217;t scan the same single photo twice:</p>
<p><img class="size-full wp-image-1137 alignnone" title="20110219-marked-photos" src="http://paperjammed.com/wp-content/uploads/2011/02/20110219-marked-photos.jpg" alt="" width="500" height="375" /></p>
<p>That&#8217;s right, I leave breadcrumbs in the form of little dots on the back of each one.</p>
<p>Such a simple thing, but it saves me from a lot of head scratching and wasted time scanning the same stuff over and over.</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2011/02/19/another-fifty-pictures-scanned-and-ten-thousand-to-go-where-did-i-leave-off/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A couple of AppleScript droplets to tweak EXIF timestamps</title>
		<link>http://paperjammed.com/2011/02/14/a-couple-of-applescript-droplets-to-tweak-exif-timestamps/</link>
		<comments>http://paperjammed.com/2011/02/14/a-couple-of-applescript-droplets-to-tweak-exif-timestamps/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 04:52:45 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Files and Folders]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[Photos]]></category>
		<category><![CDATA[Scanning]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=1114</guid>
		<description><![CDATA[Most of the time I don&#8217;t really bother with the timestamp information that my camera embeds in each digital photo. In fact, I can&#8217;t remember the last time I checked to see if the clock was right. Scanned photographs are an entirely different brew. They typically represent events from the distant past, and scanner software [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-1116" title="iStock_000010531463XSmall" src="http://paperjammed.com/wp-content/uploads/2011/02/iStock_000010531463XSmall-300x193.jpg" alt="" width="300" height="193" />Most of the time I don&#8217;t really bother with the timestamp information that my camera embeds in each digital photo. In fact, I can&#8217;t remember the last time I checked to see if the clock was right.</p>
<p>Scanned photographs are an entirely different brew. They typically represent events from the distant past, and scanner software EXIF data is hit or miss.</p>
<p>I looked for commercial software to handle a few special cases of EXIF data troubles, but came up empty handed. So I wrote a few useful AppleScript droplets that do these tasks quite nicely, and I will share them here.<span id="more-1114"></span></p>
<p><strong>Warning!</strong></p>
<p>These scripts use <strong>jhead</strong> to manipulate and <em>rewrite</em> your JPEG files!</p>
<p>Don&#8217;t be a fool. Experiment first with a safe set of throwaway JPEGs. And never use these tools on original files; always keep a backup.</p>
<p><strong>Prerequisite</strong></p>
<p>All of these scripts depend on a fine piece of free software called <a href="http://www.sentex.net/~mwandel/jhead/">jhead</a> written by <a href="http://www.sentex.net/~mwandel/index.html">Matthias Wandel</a>.</p>
<p>Installation is not difficult, but it does involve the command line.</p>
<ul>
<li>Go to the <a href="http://www.sentex.net/~mwandel/jhead/">jhead site</a></li>
<li>Scroll down to the <strong>Releases</strong> section and look for <strong>Pre-built OS-X Intel executable</strong></li>
<li>Right click on the <strong>jhead</strong> link on that row and choose <strong>Save Linked File to &#8220;Downloads&#8221;</strong></li>
</ul>
<p>At this point, I found that <strong>jhead</strong> was saved as <strong>jhead.txt</strong>. Oh well. We needed to do some command-line magic anyway.</p>
<ul>
<li>Open a terminal window and enter the following:</li>
</ul>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads<br />
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> jhead.txt jhead<br />
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> jhead<br />
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> jhead <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin</div></td></tr></tbody></table></div>
<p>These lines do the following:</p>
<ul>
<li>Lines 1 and 2 navigate to the Downloads directory and remove the &#8220;.txt&#8221; from the name</li>
<li>Line 3 makes the file executable by everyone on your Mac</li>
<li>Line 4 places the file in a public area where everyone on your Mac can see it (you will be prompted for your password)</li>
</ul>
<p><strong>Stripping All EXIF Data</strong></p>
<p>Sometimes I receive files that have corrupt EXIF data. I had a large quantity of scanned files in my collection that claimed to be scanned some time in 2038, while others insisted that they had been around since 1901. Neither situation is good, and I found that standard EXIF editing tools may fail to change these corrupt EXIF sections.</p>
<p>The answer is to blow away the EXIF data.</p>
<p>Download: <a href="http://paperjammed.com/wp-content/uploads/2011/02/Strip-EXIF.zip">Strip EXIF</a></p>
<p>This zip file contains a compiled AppleScript application. You can unzip it and place the application on your desktop. Safari will probably unzip it for you when you click the link.</p>
<p>To be safe, open AppleScript Editor and use it to open the <strong>Strip EXIF</strong> app to see its magic.</p>
<p>Now you can drop any number of JPEG files onto the <strong>Strip EXIF</strong> app and it will kindly eviscerate each JPEG, removing all traces of EXIF data.</p>
<p><strong>Adding Basic EXIF Data to a vanilla JPEG</strong></p>
<p>Some tools create JPEG files without EXIF date and time information within. This is typically the hallmark of photo manipulation software and dodgy scanner software. And if you happened to use the <strong>Strip EXIF</strong> app to rip out a bad EXIF block, then you will want to replace it with a proper data block so that you can still use camera date and timestamps.</p>
<p>Download: <a href="http://paperjammed.com/wp-content/uploads/2011/02/Add-Basic-EXIF.zip">Add Basic EXIF</a></p>
<p>Again, unzip the file, place the app on your desktop, and then drop any number of JPEG files onto <strong>Add Basic EXIF</strong>.</p>
<p>The app will set the EXIF date to the file creation timestamp.</p>
<p><strong>Spreading EXIF Timestamps</strong></p>
<p>This is the real reason why I wrote these scripts. I couldn&#8217;t find a satisfactory tool on the market that would allow me to automatically spread out the shooting times for a series of images.</p>
<p>Why would anyone want to do this? Because some processes give you fifty JPEG files all with the exact same creation time and exact same shooting time. I like to use file renaming tools to incorporate the shooting time in the filename, so that files sort by chronological order. This doesn&#8217;t work if all of the timestamps are the same.</p>
<p>So I wrote a little app that adjusts the first photo by one minute, the second by two minutes, and so on. If there are fifty photos, then the last one will have its shooting time adjusted by fifty minutes.</p>
<p>The result is a series of photos/scans that have different timestamps.</p>
<p>Download: <a href="http://paperjammed.com/wp-content/uploads/2011/02/Spread-EXIF-Timestamps.zip">Spread EXIF Timestamps</a></p>
<p>Again, please look at the short program before you run it.</p>
<p><strong>Closing Thoughts</strong></p>
<p>I hope that my favorite tool implements these tricks soon (<strong>A Better Finder Attributes</strong>, I&#8217;m looking at you!), but until then, I will be dropping my files onto these three little droplets.</p>
<p>The <strong>jhead</strong> tool is so versatile that I will probably end up with a whole slew of similar droplets that will do all kinds of spiffy stuff. Nevertheless, I would rather the commercial products already provided these features. Not everyone likes dipping into AppleScript and the command line!</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2011/02/14/a-couple-of-applescript-droplets-to-tweak-exif-timestamps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A handful of sweet freebie tools to save the day</title>
		<link>http://paperjammed.com/2010/03/16/a-handful-of-sweet-freebie-tools-to-save-the-day/</link>
		<comments>http://paperjammed.com/2010/03/16/a-handful-of-sweet-freebie-tools-to-save-the-day/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 03:31:14 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Searching and Indexing]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=930</guid>
		<description><![CDATA[It so happens that my employer has made a most welcome decision to replace the aging creaky old Novell GroupWise mail software with Microsoft Outlook, joining the rest of the modern corporate world. Now, there is little love in my heart for GroupWise, but it does have one feature that the new Outlook configuration will [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-935" title="iStock_000000846660XSmall" src="http://paperjammed.com/wp-content/uploads/2010/03/iStock_000000846660XSmall-300x199.jpg" alt="" width="300" height="199" />It so happens that my employer has made a most welcome decision to replace the aging creaky old Novell GroupWise mail software with Microsoft Outlook, joining the rest of the modern corporate world. Now, there is little love in my heart for GroupWise, but it does have one feature that the new Outlook configuration will lack: you can keep as many emails as you want, just like Gmail.</p>
<p>The problem is this: with Outlook we will be limited to 1000 messages in our in-box; sadly, many of us have tens of thousands of emails in our old GroupWise mail. Even after a fairly rigorous slash and burn mission, hacking out all of the low hanging fruit, there will be many thousands remaining and I don&#8217;t want to lose that information. It might be useful to search and find how I set up a Zebra bar code printer in 2003, no?</p>
<p>A bundle of different freeware glue tools came to my rescue. Read on to hear about the toolset that has made it so I can keep those messages for years to come.<span id="more-930"></span></p>
<p><strong>Possible Solutions</strong></p>
<p>Right out of the gate, I began looking for ways to migrate messages from one mail client to the other. Some apps have this built right in, and if not, there are scripts and utilities out there to do this; but I was hampered by a few key facts:</p>
<ul>
<li>I have no control over the email clients and their configuration. Even if there is a menu option for exporting GroupWise messages from version 7.2, I&#8217;m stuck at 6.4 and cannot use that option.</li>
<li>GroupWise is a minor player in the email world. I&#8217;m not sure if Outlook would import from GroupWise, but I doubt it.</li>
<li>They are <em>replacing</em> the client in one shot. There will be no interim period where both GroupWise and Outlook will be available.</li>
<li>There is no getting around the hard limit of 1000 messages.</li>
<li>I don&#8217;t want to spend money on this.</li>
</ul>
<p>With these constraints in mind, I immediately thought about PDF documents. I then considered the following questions:</p>
<ul>
<li>How do I convert my email to PDF?</li>
<li>How can I do this automatically with thousands of emails?</li>
<li>Once I&#8217;m done, how do I search these documents?</li>
</ul>
<p>Here&#8217;s what I did:</p>
<p><strong>Conversion to PDF</strong></p>
<p>The first part was easy. I downloaded one of the many free print-to-PDF products available.</p>
<p>I chose <a href="http://sourceforge.net/projects/pdfcreator/">PDFCreator</a>, because I am familiar with its use and I know that it <a href="http://paperjammed.com/2009/10/27/dodged-the-corrupt-document-bullet-this-time-just-barely/">does not munge the fonts</a>.</p>
<p>Like many other PDF generation utilities, PDFCreator functions by providing a virtual printer to which any application can print. For example, to make a PDF of a web page, you use the Firefox <strong>Print</strong> menu and select <strong>PDFCreator</strong> from the drop-down list of available printers.</p>
<p>You are provided with a list of metadata fields that you can fill in, and these fields are used in the PDF generation.</p>
<p>Here&#8217;s what the PDFCreator screen looks like:</p>
<p><img class="alignnone size-full wp-image-931" title="20100316-pdfcreator1" src="http://paperjammed.com/wp-content/uploads/2010/03/20100316-pdfcreator1.gif" alt="" width="500" height="367" /></p>
<p><strong>A word of caution:</strong> PDF Creator is free, but you must be careful to deselect their spammy toolbar options in two different places during the installation process. I don&#8217;t like software that comes with preselected toolbars to install (even nice ones like Google&#8217;s) because I&#8217;m certain that 95% of the folks who actually install the toolbar would never have chosen to do so if it were unchecked by default.</p>
<p><strong>Running Everything Automatically</strong></p>
<p>This was the interesting bit. I work with Windows machines at work, so there was no AppleScript option available. So I did the next best thing: I used <a href="http://www.autoitscript.com/autoit3/index.shtml">AutoIT</a>.</p>
<p>I will warn you that AutoIT is pretty much the Windows analog of AppleScript, without the cutesy pseudo English syntax. In other words, you will need to roll up your sleeves and get your hands a little dirty in order to put together a decent AutoIT script.</p>
<p>The payoff comes when you finish your work and compile it into a tight executable that you can share with your friends, allowing them to automate some complex series of button clicks and copy/paste operations.</p>
<p>I walked through the manual process of exporting an email to PDF and listed each action:</p>
<ul>
<li>Get the date, sender, and subject</li>
<li>Create a filename based on date + sender + subject</li>
<li>Launch the <strong>Print</strong> dialog</li>
<li>Select <strong>PDFCreator</strong></li>
<li>Fill in the <strong>Document Title</strong>, <strong>Creation Date</strong>, and <strong>Subject</strong> in the PDFCreator dialog</li>
<li>Fill in the full file path in the Save dialog</li>
</ul>
<p>In addition, I wanted to make the script a little better by adding the following:</p>
<ul>
<li>Check that user has PDFCreator installed</li>
<li>Verify that GroupWise is running and that the user has selected one or more messages</li>
<li>Prompt the user for a target directory before processing the messages</li>
<li>Sanitize the filenames by replacing illegal characters with underscores and truncating to meet maximum filename and path length in Windows</li>
<li>Skip over files that have already been generated, quickly, so that one doesn&#8217;t need to worry about accidentally selecting messages that were already printed</li>
</ul>
<p>There were other adjustments needed, but the process was the same: run the script, hit a problem, tweak the script a little to address the problem, and repeat.</p>
<p>Here&#8217;s a little bit of the AutoIT script:</p>
<p><img class="size-full wp-image-943 alignnone" title="20100316-autoit" src="http://paperjammed.com/wp-content/uploads/2010/03/20100316-autoit.gif" alt="" width="500" height="345" /></p>
<p>You can see that it is a bit more intense than AppleScript, but remember that the full script wasn&#8217;t written in one go. I had a little short ten-line script that I kept tweaking as small problems cropped up until I had adjusted things to my liking.</p>
<p>Note that this is a GUI macro language. The machine starts clicking and typing away right in front of you and you probably shouldn&#8217;t interfere until your script finishes.</p>
<p>As of this afternoon, I have generated around 4,000 PDF documents for my email messages.</p>
<p><strong>Searching All of Those Documents</strong></p>
<p>This was the easiest part. These days there is an excellent tool available for searching documents on your desktop: <a href="http://desktop.google.com/">Google Desktop</a>. This product indexes every useful file on your desktop and provides a full Google search with a quick double-tap of the &lt;control&gt; key.</p>
<p>So you can enter a search like &#8220;Zebra bar code&#8221;</p>
<p><img class="alignnone size-full wp-image-944" title="20100316-google1" src="http://paperjammed.com/wp-content/uploads/2010/03/20100316-google1.gif" alt="" width="300" height="205" /></p>
<p>And the results look exactly like a Google web search, but it&#8217;s showing your desktop files. And you can see inline previews too.</p>
<p><img class="alignnone size-full wp-image-945" title="20100316-google2" src="http://paperjammed.com/wp-content/uploads/2010/03/20100316-google2.gif" alt="" width="500" height="443" /></p>
<p>Macintosh users can install Google Desktop as well, but all of these files should already be indexed and searchable by Spotlight.</p>
<p><strong>Closing Thoughts</strong></p>
<p>Whenever I reach for tools like this I feel a twinge of guilt—it&#8217;s outright hackery, isn&#8217;t it?</p>
<p>But there is a place for quick and dirty jobs in every workplace. I needed to get my files from one place to another, one time only. It just didn&#8217;t make sense to spend money or time on a more elegant solution.</p>
<p>Play around with each of these tools a little. Especially AutoIT—it&#8217;s a handy Swiss Army Knife to have at your disposal.</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2010/03/16/a-handful-of-sweet-freebie-tools-to-save-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automate ScanSnap OCR process on your Mac with AppleScript (Snow Leopard Edition)</title>
		<link>http://paperjammed.com/2010/01/04/automate-scansnap-ocr-process-on-your-mac-with-applescript-snow-leopard-edition/</link>
		<comments>http://paperjammed.com/2010/01/04/automate-scansnap-ocr-process-on-your-mac-with-applescript-snow-leopard-edition/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 01:51:52 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Scanning]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Searching and Indexing]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=840</guid>
		<description><![CDATA[Some time back I published an AppleScript that allows one to automatically run OCR in the background on scanned files generated by your Fujitsu ScanSnap, while you to continue scanning more files. ScanSnap owners should all be familiar with this: the out-of-the-box configuration of the ScanSnap Manager and Abbyy Finereader force the scan and OCR [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://paperjammed.com/wp-content/uploads/2009/08/20090829-applescript.gif"><img class="alignright size-full wp-image-658" title="20090829-applescript" src="http://paperjammed.com/wp-content/uploads/2009/08/20090829-applescript.gif" alt="" width="128" height="128" /></a>Some time back I published an AppleScript that allows one to <a href="http://paperjammed.com/2009/08/29/automate-scansnap-ocr-process-on-your-mac-with-applescript/">automatically run OCR in the background on scanned files</a> generated by your Fujitsu ScanSnap, while you to continue scanning more files. ScanSnap owners should all be familiar with this: the out-of-the-box configuration of the ScanSnap Manager and Abbyy Finereader force the scan and OCR stages to run in lockstep: scan 1&#8230;OCR 1&#8230;scan 2&#8230;OCR 2&#8230; and so on. This script allowed you to scan regardless of the OCR processing going on.</p>
<p>As it turns out, my original script does not work in Snow Leopard, and I promised that I would one day clean up and publish my new and improved version.</p>
<p>Chris posted a comment today as a gentle reminder, so here is the new and improved version without further delay&#8230;<br />
<span id="more-840"></span><br />
<strong>The Details</strong></p>
<p>Unfortunately, Snow Leopard came around <a href="http://paperjammed.com/2009/09/07/when-migrating-to-a-new-operating-system-look-before-you-leap/">and caused some indigestion</a>. For starters, the ScanSnap Manager didn&#8217;t work correctly and Abbyy Finereader would not process anything made by the ScanSnap. A couple of months later <a href="http://paperjammed.com/2009/11/13/snow-leopard-update-for-scansnap/">they got everything straightened out</a> and delivered <a href="http://www.fujitsu.com/us/services/computing/peripherals/scanners/support/sl_download.html">new versions of each product</a>.</p>
<p>The new version of the Abbyy Finereader product does not play well with my original script.</p>
<p>Since I cannot do without this important functionality, I rolled up my sleeves and rewrote most of the script. The new version works in Snow Leopard quite nicely with one small annoyance: you really don&#8217;t want to try to use the machine for anything other than scanning or OCR while it is going because the new Finereader version keeps bouncing the darned icon all the time it is running and that is quite annoying to watch.</p>
<p>Fortunately, I really don&#8217;t need to use my machine for anything else while it is chewing on the docs; I just wanted to be able to continue scanning at the same time!</p>
<p><strong>Note: </strong>Before going forward, note that you will need to upgrade the ScanSnap Manager and Abbyy Finereader to the Snow Leopard versions first! Get the files <a href="http://www.fujitsu.com/us/services/computing/peripherals/scanners/support/sl_download.html">here</a>.</p>
<p>Here is a link to the <a href="http://paperjammed.com/wp-content/uploads/2010/01/Run-OCR-on-New-Folder-Items.scpt">new script</a>&#8230;</p>
<p>And here&#8217;s the code itself:</p>
<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br /></div></td><td><div class="applescript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">(*<br />
<br />
NOTE: This script was written for Snow Leopard. It may work<br />
on Leopard, but I never tried it.<br />
<br />
This is a folder listener script that will act as a queue, receiving<br />
PDF files from the ScanSnap scanner and feeding them, one by one, to<br />
the Abbyy FineReader OCR software.<br />
<br />
This allows you to keep scanning while the OCR job runs in the background<br />
on all of the unprocessed files.<br />
<br />
Why do we want to do this?<br />
<br />
The ScanSnap Manager software does not support this by default, so<br />
when you scan in a file, it sends it to FineReader for OCR. You then<br />
must wait until FineReader finishes its work before scanning in another<br />
document.<br />
<br />
This script allows you to keep scanning without waiting for OCR.<br />
<br />
Installation:<br />
<br />
o &nbsp; Copy this script to:<br />
<br />
&nbsp; &nbsp; &lt;home&gt;/Library/Scripts/Folder Action Scripts<br />
<br />
&nbsp; &nbsp; You may have to create the &quot;Folder Action Scripts&quot; folder.<br />
<br />
o &nbsp; Open a Finder window and navigate to the parent folder<br />
&nbsp; of the scanned documents folder.<br />
<br />
o Right click (control-click) the scanned documents folder and<br />
&nbsp; choose:<br />
<br />
&nbsp; &nbsp; Folder Actions Setup...<br />
<br />
o At this point if folder actions are not enabled, you will<br />
&nbsp; likely have to enable them and add the script manually.<br />
&nbsp; &nbsp; - check &quot;Enable Folder Actions&quot;<br />
&nbsp; &nbsp; - Use the &quot;+&quot; buttons on the left and right sides to add the<br />
&nbsp; &nbsp; &nbsp; scan folder and then this script.<br />
&nbsp; &nbsp; <br />
o Otherwise, a list of scripts will come up. Choose this script<br />
&nbsp; from the &quot;Choose a Script to Attach&quot; dialog.<br />
<br />
o Close all windows.<br />
<br />
Copyright (C) 2010 Tad Harrison<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">property</span> ocrFileSuffix : <span style="color: #009900;">&quot; processed by FineReader.pdf&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">property</span> ocrApplicationName : <span style="color: #009900;">&quot;Scan to Searchable PDF&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">property</span> ocrApplicationWindow : <span style="color: #009900;">&quot;Converting the document&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">property</span> ocrLockFileName : <span style="color: #009900;">&quot;OCR in Progress&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span> this_folder <span style="color: #ff0033;">after</span> <span style="color: #0066ff;">receiving</span> added_items<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> lockFilePath <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">path to</span> <span style="color: #0066ff;">desktop</span> <span style="color: #0066ff;">folder</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">text</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> ocrLockFileName<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; logEvent<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;=== Run OCR on New Folder Items ===&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Test for lockfile; exit if lockfile exists</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> lockFileExists <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">exists</span> <span style="color: #0066ff;">file</span> lockFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> lockFileExists <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; logEvent<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;Other script running. Exiting...&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;/usr/bin/touch <span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000;">&amp;</span> lockFilePath <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;<span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Main loop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> moreWorkToDo <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">while</span> moreWorkToDo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> aFile <span style="color: #ff0033; font-weight: bold;">to</span> getNextFile<span style="color: #000000;">&#40;</span>this_folder<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">not</span> aFile <span style="color: #000000;">=</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ocrFile<span style="color: #000000;">&#40;</span>aFile<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> moreWorkToDo <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; logEvent<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;No more work.&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; exitApp<span style="color: #000000;">&#40;</span>ocrApplicationName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span> errorStr <span style="color: #0066ff;">number</span> errNum<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Error &quot;</span> <span style="color: #000000;">&amp;</span> errNum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; while running OCR: &quot;</span> <span style="color: #000000;">&amp;</span> errorStr<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033; font-weight: bold;">my</span> isRunning <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Get rid of the lockfile, ignoring any errors</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;/bin/rm <span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000;">&amp;</span> lockFilePath <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;<span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span><br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: ocrFile<br />
Description: Runs OCR on the next un-OCR'd file<br />
Parameters:<br />
&nbsp; aFile - the file to be OCR'd<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> ocrFile<span style="color: #000000;">&#40;</span>aFile<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixFilePath <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> aFile<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixOcrFilePath <span style="color: #ff0033; font-weight: bold;">to</span> getPosixOcrFilePath<span style="color: #000000;">&#40;</span>posixFilePath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; logEvent<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;OCR: &quot;</span> <span style="color: #000000;">&amp;</span> posixFilePath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> ocrApplicationName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">open</span> aFile<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Now sit in a loop checking once per second for the OCR file</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Give up after five minutes</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #ff0033; font-weight: bold;">timeout</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">300</span> seconds<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> ocrFileExists <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">until</span> ocrFileExists<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> ocrFileExists <span style="color: #ff0033; font-weight: bold;">to</span> posixFileExists<span style="color: #000000;">&#40;</span>posixOcrFilePath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> ocrFileExists <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; logEvent<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;OCR file generated.&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Wait 5 even if the file was found, to let things settle</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay <span style="color: #000000;">5</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Wait a second before checking again</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">timeout</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> ocrFile<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: appIsRunning<br />
Description: Determines if a particular application is running.<br />
Parameters:<br />
&nbsp; &nbsp; appName - the name of the application to be tested<br />
Returns: True if the application is running; otherwise False<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> appIsRunning<span style="color: #000000;">&#40;</span>appName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">contains</span> appName<br />
<span style="color: #ff0033; font-weight: bold;">end</span> appIsRunning<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: posixFileExists<br />
Description: Determines if a particular file exists.<br />
Parameters:<br />
&nbsp; &nbsp; posixFilePath - the POSIX path to the file<br />
Returns: True if the file exists; otherwise False<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> posixFileExists<span style="color: #000000;">&#40;</span>posixFilePath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">exists</span> <span style="color: #0066ff;">file</span> posixFilePath<br />
<span style="color: #ff0033; font-weight: bold;">end</span> posixFileExists<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: exitApp<br />
Description: Exits the specified app if it is running.<br />
Parameters:<br />
&nbsp; &nbsp; appName - the application name<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> exitApp<span style="color: #000000;">&#40;</span>appName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> appIsRunning<span style="color: #000000;">&#40;</span>appName<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> appName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">quit</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> exitApp<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: getPosixOcrFilePath<br />
Description: Gets the OCR output filename for a given input filename.<br />
Parameters:<br />
&nbsp; &nbsp; posixFilePath - the full path to the source file<br />
Return: the POSIX path of the OCR output file<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> getPosixOcrFilePath<span style="color: #000000;">&#40;</span>posixFilePath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixBaseName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do shell script</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;filename=&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> posixFilePath <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;; echo ${filename%<span style="color: #000000; font-weight: bold;">\\</span>.*}&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixOcrFilePath <span style="color: #ff0033; font-weight: bold;">to</span> posixBaseName <span style="color: #000000;">&amp;</span> ocrFileSuffix<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> posixOcrFilePath<br />
<span style="color: #ff0033; font-weight: bold;">end</span> getPosixOcrFilePath<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: getNextFile<br />
Description: Finds the next unprocessed ScanSnap PDF<br />
Return: the file or &quot;&quot;<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> getNextFile<span style="color: #000000;">&#40;</span>aFolder<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; logEvent<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;Getting next file...&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> masterFileList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">list</span> <span style="color: #0066ff;">folder</span> aFolder ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">without</span> <span style="color: #0066ff;">invisibles</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixPath <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> aFolder<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">count</span> masterFileList<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> fileName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> masterFileList<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixFilePath <span style="color: #ff0033; font-weight: bold;">to</span> posixPath <span style="color: #000000;">&amp;</span> fileName<br />
&nbsp; &nbsp; &nbsp; &nbsp; log posixFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Construct a FineReader file name from our file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixOcrFilePath <span style="color: #ff0033; font-weight: bold;">to</span> getPosixOcrFilePath<span style="color: #000000;">&#40;</span>posixFilePath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- See if the FineReader file we constructed exists</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> ocrFileExists <span style="color: #ff0033; font-weight: bold;">to</span> posixFileExists<span style="color: #000000;">&#40;</span>posixOcrFilePath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">me</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> fileCreator <span style="color: #ff0033; font-weight: bold;">to</span> getSpotlightInfo for <span style="color: #009900;">&quot;kMDItemCreator&quot;</span> <span style="color: #ff0033; font-weight: bold;">from</span> posixFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; log <span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;Creator: &quot;</span> <span style="color: #000000;">&amp;</span> fileCreator<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">not</span> ocrFileExists <span style="color: #ff0033;">and</span> fileCreator <span style="color: #000000;">=</span> <span style="color: #009900;">&quot;ScanSnap Manager&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">POSIX file</span> posixFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #009900;">&quot;&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> getNextFile<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: getSpotlightInfo<br />
Description: Gets a named attribute from metadata for a specific file.<br />
Parameters:<br />
&nbsp; &nbsp; for myattribute - the name of the attribute<br />
&nbsp; &nbsp; from myfile - the name of the file<br />
Returns: the attribute value or &quot;&quot; if none found<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> getSpotlightInfo for myattribute <span style="color: #ff0033; font-weight: bold;">from</span> myfile<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_item <span style="color: #ff0033; font-weight: bold;">to</span> myfile <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_item<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItem <span style="color: #ff0033; font-weight: bold;">to</span> myattribute<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> theResult <span style="color: #ff0033; font-weight: bold;">to</span> words <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;/usr/bin/mdls -name &quot;</span> <span style="color: #000000;">&amp;</span> this_kMDItem <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; -raw -nullMarker None &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_item<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log <span style="color: #009900;">&quot;Result: &quot;</span> <span style="color: #000000;">&amp;</span> theResult <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> j <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> theResult<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> this_kMDItemResult <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">item</span> j <span style="color: #ff0033; font-weight: bold;">of</span> theResult <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> j <span style="color: #000000;">&lt;</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> theResult <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> this_kMDItemResult <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> this_kMDItemResult<br />
<span style="color: #ff0033; font-weight: bold;">end</span> getSpotlightInfo<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: logEvent<br />
Description: Write an event to an event log<br />
Parameters:<br />
&nbsp; &nbsp; themessage - the message to write to the log<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> logEvent<span style="color: #000000;">&#40;</span>themessage<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> theLine <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">do shell script</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;date &nbsp;+'%Y-%m-%d %H:%M:%S'&quot;</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> themessage<br />
&nbsp; &nbsp; <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;echo &quot;</span> <span style="color: #000000;">&amp;</span> theLine <span style="color: #000000;">&amp;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot; &gt;&gt; ~/Library/Logs/AppleScript-events.log&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> logEvent</div></td></tr></tbody></table></div>
<p><strong>Installation</strong></p>
<ul>
<li>Use the Script Editor to save this script as <strong>Run OCR on New Folder Items</strong> under <strong><em>User Home</em>/Library/Scripts/Folder Action Scripts</strong><br />
You may have to create the <strong>Folder Action Scripts</strong> folder.</li>
<li>Now open a Finder window and navigate to the parent folder of your scanned documents folder.</li>
<li>Right click (control-click) the scanned documents folder and choose <strong>Folder Actions Setup&#8230;</strong></li>
<li>At this point if folder actions are not enabled, you will likely have to enable them and add the script manually.
<ul>
<li> Check <strong>Enable Folder Actions</strong></li>
<li>Use the &#8220;+&#8221; buttons on the left and right sides to add the scan folder and then this script.</li>
</ul>
</li>
<li>Otherwise, a list of scripts will come up. Choose this script from the <strong>Choose a Script to Attach</strong> dialog.</li>
<li>Close all windows.</li>
</ul>
<p>That&#8217;s it! The script will be invoked automatically every time a new file appears in your scanned documents folder.</p>
<p>Please let me know if you have any ideas that can improve this script. I&#8217;m not an AppleScript guru, so someone might just know how to keep that annoying Finereader icon from jumping.</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2010/01/04/automate-scansnap-ocr-process-on-your-mac-with-applescript-snow-leopard-edition/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Automate ScanSnap OCR process on your Mac with AppleScript</title>
		<link>http://paperjammed.com/2009/08/29/automate-scansnap-ocr-process-on-your-mac-with-applescript/</link>
		<comments>http://paperjammed.com/2009/08/29/automate-scansnap-ocr-process-on-your-mac-with-applescript/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 23:50:08 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Scanning]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Searching and Indexing]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=648</guid>
		<description><![CDATA[Some months back I wrote an article on using scripting languages to glue workflows together. My inspiration for that article was a bit of AppleScript that I had suffered over in order to smooth over a minor annoyance of my scan-to-OCR workflow. I had promised that once I cleaned up the embarrassing bits of code [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-658" src="http://paperjammed.com/wp-content/uploads/2009/08/20090829-applescript.gif" alt="" width="128" height="128" />Some months back I wrote an article on using scripting languages to glue workflows together. My inspiration for that article was a bit of AppleScript that I had suffered over in order to smooth over a minor annoyance of my scan-to-OCR workflow.</p>
<p>I had promised that once I cleaned up the embarrassing bits of code I would post a perfect polished version here, but such promises are rarely fulfilled. A reader posted a comment asking for that source code, so I will post it here in its current state. The truth is, I have been using this script for months and, though it has some quirks, it works fine.</p>
<p>So this post is about Macintosh, AppleScript, and the ScanSnap-to-FineReader workflow. If these don&#8217;t interest you, better move on.</p>
<p><b>Update:</b> The script on this page works only with Leopard (10.5). Get the Snow Leopard version <a href="http://paperjammed.com/2010/01/04/automate-scansnap-ocr-process-on-your-mac-with-applescript-snow-leopard-edition/">here</a><br />
<span id="more-648"></span></p>
<p><strong>The Original Problem</strong></p>
<p>The Fujitsu ScanSnap S510m, my workhorse scanner, was designed to scan documents quickly and generate PDF files—this it does flawlessly. In order to provide OCR support, they have shipped a special version of <a href="http://finereader.abbyy.com/">FineReader</a>, called <strong>FineReader for ScanSnap</strong>. The standard OCR configuration is to chain the output of the scanner to the FineReader program.</p>
<p>The problem is that this forces scanning and OCR to run in lockstep: you scan a document, you wait for OCR, and then you scan another document.</p>
<p>My desire was to write a simple AppleScript that would detach the &#8220;Scan a Document&#8221; process from the &#8220;OCR&#8221; process. By using this script, I can scan documents at whatever rate pleases me, and the OCR engine will chunk along at its own pace, consuming my scanned documents and producing OCR documents.</p>
<p><strong>My Approach</strong></p>
<p>I really looked hard at the OCR application, trying to find AppleScript hooks or special command line switches that might allow me to control it better. Sadly, it was not designed to be scriptable. The only thing I could do is call the FineReader application with a source file.</p>
<p>Given this limitation, I considered writing a script that would look at a particular folder, identifying new files as they appear and passing them on to FineReader.</p>
<p>Fortunately, AppleScript provides this kind of functionality with little effort in the form of <strong>Folder Actions</strong>. Perhaps the best way to see these in action (and try it out) is to see this post on <a href="http://www.tuaw.com/2009/02/16/applescript-exploring-the-power-of-folder-actions-part-i/">Exploring the power of Folder Actions</a>.</p>
<p>In order to achieve my goals, I did the following:</p>
<ul>
<li>Created a folder called &#8220;Pending Documents&#8221;</li>
<li>Wrote the script to find the oldest-unprocessed-file and call FineReader with it</li>
<li>Attached the script to the folder as a Folder Action</li>
</ul>
<p><strong>The Script</strong></p>
<p>Let&#8217;s jump right in to the AppleScript. <a href="http://paperjammed.com/wp-content/uploads/2009/08/Run-OCR-on-New-Folder-Items.scpt">Download the script here.</a></p>
<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br /></div></td><td><div class="applescript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">(*<br />
This is a folder listener script that will act as a queue, receiving<br />
PDF files from the ScanSnap scanner and feeding them, one by one, to<br />
the Abbyy FineReader OCR software.<br />
<br />
This allows you to keep scanning while the OCR job runs in the background<br />
on all of the unprocessed files.<br />
<br />
Why do we want to do this?<br />
<br />
The ScanSnap Manager software does not support this by default, so<br />
when you scan in a file, it sends it to FineReader for OCR. You then<br />
must wait until FineReader finishes its work before scanning in another<br />
document.<br />
<br />
This script allows you to keep scanning without waiting for OCR.<br />
<br />
Installation:<br />
<br />
o &nbsp; Copy this script to:<br />
<br />
&nbsp; &nbsp; &lt;home&gt;/Library/Scripts/Folder Action Scripts<br />
<br />
&nbsp; &nbsp; You may have to create the &quot;Folder Action Scripts&quot; folder.<br />
<br />
o &nbsp; Now open a Finder window, control-click and choose:<br />
<br />
&nbsp; &nbsp; More / Configure Folder Actions...<br />
<br />
o &nbsp; Check the &quot;Enable Folder Actions&quot; checkbox, if not checked<br />
o &nbsp; Click the &quot;+&quot; in the bottom left<br />
o &nbsp; Select a folder and click Open<br />
o &nbsp; Choose the script &quot;Run OCR on New Folder Items&quot; and click Attach<br />
<br />
Copyright (C) 2009 Tad Harrison<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span> this_folder <span style="color: #ff0033;">after</span> <span style="color: #0066ff;">receiving</span> added_items<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Just in case FineReader is running, wait until it is ready</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; waitForFineReaderFinish<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> moreWorkToDo <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">while</span> moreWorkToDo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> aFile <span style="color: #ff0033; font-weight: bold;">to</span> getNextFile<span style="color: #000000;">&#40;</span>this_folder<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">not</span> aFile <span style="color: #000000;">=</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> aFile<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ocrFile<span style="color: #000000;">&#40;</span>aFile<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> moreWorkToDo <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; exitApp<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;FineReader for ScanSnap&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span> errorStr <span style="color: #0066ff;">number</span> errNum<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Error &quot;</span> <span style="color: #000000;">&amp;</span> errNum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; while running OCR: &quot;</span> <span style="color: #000000;">&amp;</span> errorStr<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span><br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: ocrFile<br />
Description: Runs OCR on the next un-OCR'd file<br />
Parameters:<br />
&nbsp; aFile - the file to be OCR'd<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> ocrFile<span style="color: #000000;">&#40;</span>aFile<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;FineReader for ScanSnap&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">open</span> aFile<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Make sure FineReader actually starts before we start waiting for it to stop</span><br />
&nbsp; &nbsp; waitForFineReaderStart<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Now wait 'till it's done so we do one file at a time</span><br />
&nbsp; &nbsp; waitForFineReaderFinish<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> ocrFile<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: appIsRunning<br />
Description: Determines if a particular application is running.<br />
Parameters:<br />
&nbsp; &nbsp; appName - the name of the application to be tested<br />
Returns: True if the application is running; otherwise False<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> appIsRunning<span style="color: #000000;">&#40;</span>appName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">contains</span> appName<br />
<span style="color: #ff0033; font-weight: bold;">end</span> appIsRunning<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: exitApp<br />
Description: Exits the specified app if it is running.<br />
Parameters:<br />
&nbsp; &nbsp; appName - the application name<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> exitApp<span style="color: #000000;">&#40;</span>appName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> appIsRunning<span style="color: #000000;">&#40;</span>appName<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> appName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">quit</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> exitApp<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: getNextFile<br />
Description: Finds the next unprocessed ScanSnap PDF<br />
Return: the file or &quot;&quot;<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> getNextFile<span style="color: #000000;">&#40;</span>aFolder<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> masterFileList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">list</span> <span style="color: #0066ff;">folder</span> aFolder ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">without</span> <span style="color: #0066ff;">invisibles</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixPath <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> aFolder<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">count</span> masterFileList<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> fileName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> masterFileList<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixFilePath <span style="color: #ff0033; font-weight: bold;">to</span> posixPath <span style="color: #000000;">&amp;</span> fileName<br />
&nbsp; &nbsp; &nbsp; &nbsp; log posixFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Construct a FineReader file name from our file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixBaseName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do shell script</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;filename=&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> posixFilePath <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;; echo ${filename%<span style="color: #000000; font-weight: bold;">\\</span>.*}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; log <span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;Name: &quot;</span> <span style="color: #000000;">&amp;</span> posixBaseName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> posixOcrFilePath <span style="color: #ff0033; font-weight: bold;">to</span> posixBaseName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; processed by FineReader.pdf&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- See if the FineReader file we constructed exists</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">--</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> ocrFileExists <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">exists</span> <span style="color: #0066ff;">file</span> posixOcrFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> ocrFileExists <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log <span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;OCR file found for &quot;</span> <span style="color: #000000;">&amp;</span> posixBaseName<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">me</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> fileCreator <span style="color: #ff0033; font-weight: bold;">to</span> getSpotlightInfo for <span style="color: #009900;">&quot;kMDItemCreator&quot;</span> <span style="color: #ff0033; font-weight: bold;">from</span> posixFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; log <span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;Creator: &quot;</span> <span style="color: #000000;">&amp;</span> fileCreator<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">not</span> ocrFileExists <span style="color: #ff0033;">and</span> fileCreator <span style="color: #000000;">=</span> <span style="color: #009900;">&quot;ScanSnap Manager&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">POSIX file</span> posixFilePath<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #009900;">&quot;&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> getNextFile<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: getSpotlightInfo<br />
Description: Gets a named attribute from metadata for a specific file.<br />
Parameters:<br />
&nbsp; &nbsp; for myattribute - the name of the attribute<br />
&nbsp; &nbsp; from myfile - the name of the file<br />
Returns: the attribute value or &quot;&quot; if none found<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> getSpotlightInfo for myattribute <span style="color: #ff0033; font-weight: bold;">from</span> myfile<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_item <span style="color: #ff0033; font-weight: bold;">to</span> myfile <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_item<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItem <span style="color: #ff0033; font-weight: bold;">to</span> myattribute<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> theResult <span style="color: #ff0033; font-weight: bold;">to</span> words <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;/usr/bin/mdls -name &quot;</span> <span style="color: #000000;">&amp;</span> this_kMDItem <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; -raw -nullMarker None &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_item<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log <span style="color: #009900;">&quot;Result: &quot;</span> <span style="color: #000000;">&amp;</span> theResult <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> j <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> theResult<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> this_kMDItemResult <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">item</span> j <span style="color: #ff0033; font-weight: bold;">of</span> theResult <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> j <span style="color: #000000;">&lt;</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> theResult <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> this_kMDItemResult <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> this_kMDItemResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> this_kMDItemResult<br />
<span style="color: #ff0033; font-weight: bold;">end</span> getSpotlightInfo<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: waitForFineReaderFinish<br />
Description: Waits until FineReader OCR is complete.<br />
Returns: True if FineReader OCR is complete; otherwise False<br />
<br />
This procedure constantly loops through open FineReader windows looking<br />
for the window called &quot;Converting the Document&quot;<br />
Once that window goes away, the procedure exits.<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> waitForFineReaderFinish<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">not</span> appIsRunning<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;FineReader for ScanSnap&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> window_found <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">until</span> <span style="color: #ff0033;">not</span> window_found<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> ew <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">window</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> process <span style="color: #009900;">&quot;FineReader for ScanSnap&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> ew <span style="color: #ff0033;">contains</span> <span style="color: #009900;">&quot;Converting the Document&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> window_found <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> window_found <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">true</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> waitForFineReaderFinish<br />
<span style="color: #808080; font-style: italic;">(*<br />
Name: waitForFineReaderStart<br />
Description: Waits until FineReader OCR has begun.<br />
Returns: True if FineReader OCR has started; otherwise False<br />
<br />
This procedure is used to give FineReader a moment to actually start<br />
chewing on a file. It simply waits for the &quot;Converting the Document&quot;<br />
window to appear.<br />
In order to avoid a permanent loop if FineReader doesn't<br />
start, this times out after 30 seconds.<br />
*)</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> waitForFineReaderStart<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">not</span> appIsRunning<span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;FineReader for ScanSnap&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #ff0033; font-weight: bold;">timeout</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">30</span> seconds<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> window_found <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">until</span> window_found<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> ew <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">window</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> process <span style="color: #009900;">&quot;FineReader for ScanSnap&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> ew <span style="color: #ff0033;">contains</span> <span style="color: #009900;">&quot;Converting the Document&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> window_found <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> window_found <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">timeout</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">true</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> waitForFineReaderStart</div></td></tr></tbody></table></div>
<p><strong>Installation</strong></p>
<ul>
<li>Use the Script Editor to save this script as <strong>Run OCR on New Folder Items</strong> under <strong><em>User Home</em>/Library/Scripts/Folder Action Scripts</strong>You may have to create the <strong>Folder Action Scripts </strong>folder.</li>
<li>Now open a Finder window, control-click and choose <strong>More / Configure Folder Actions&#8230;</strong></li>
<li>Check the <strong>Enable Folder Actions</strong> checkbox, if not checked</li>
<li>Click the &#8220;+&#8221; in the bottom left</li>
<li>Select a folder and click <strong>Open</strong></li>
<li>Choose the script <strong>Run OCR on New Folder Items</strong> and click <strong>Attach</strong></li>
</ul>
<p><strong>Picky Details</strong></p>
<p>As you can see in the source code, there were several issues to address:</p>
<ul>
<li>I had to make sure the script didn&#8217;t step on itself. If FineReader was running, I would wait until it was ready before processing.</li>
<li>The script needed to determine which files had been processed already. This was handled fairly trivially by looking for a matching file with the <strong>processed by FineReader.pdf</strong> suffix. In other words, if I was looking at <strong>Scan001.pdf</strong>, I would see if there was a matching <strong>Scan001 processed by FineReader.pdf</strong> file.</li>
<li>Part of checking for a source file&#8217;s &#8220;buddy&#8221; was stripping off the PDF suffix. This was done in a hackish way by using a one-line shell script, at lines 106-107.</li>
<li>I thought it was important to verify that the source file was, indeed, a ScanSnap file—the FineReader will not process other PDF documents. This was done at lines 117-121 by looking at the Spotlight metadata for the Creator of the source file. That took some more shell scripting (133-154).</li>
<li>The actual work was done by a single line, line 63.</li>
</ul>
<p>The real work was fairly simple, while the bulk of the code was needed to polish pesky little details. Isn&#8217;t that the way code development often is?</p>
<p>If anyone has any improvements on my script, please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2009/08/29/automate-scansnap-ocr-process-on-your-mac-with-applescript/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>HowStuffWorks — How Paperless Offices Work</title>
		<link>http://paperjammed.com/2009/07/03/howstuffworks-%e2%80%94-how-paperless-offices-work/</link>
		<comments>http://paperjammed.com/2009/07/03/howstuffworks-%e2%80%94-how-paperless-offices-work/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 00:30:42 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Green Living]]></category>
		<category><![CDATA[Paperless Life]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Good Sites]]></category>
		<category><![CDATA[Indexing]]></category>
		<category><![CDATA[Online Services]]></category>
		<category><![CDATA[Organization]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=594</guid>
		<description><![CDATA[I have always been a big fan of HowStuffWorks, with their detailed in-depth articles describing such disparate topics as manual transmissions and money laundering. Anyway, author Diane Dannenfeldt has written a lengthy article on How Paperless Offices Work, giving ample coverage to myriad aspects of the topic: Introduction to How Paperless Offices Work Benefits of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-595 alignnone" src="http://paperjammed.com/wp-content/uploads/2009/07/20090703-howstuffworks.jpg" alt="20090703-howstuffworks" width="492" height="352" /></p>
<p>I have always been a big fan of HowStuffWorks, with their detailed in-depth articles describing such disparate topics as <a href="http://auto.howstuffworks.com/transmission.htm">manual transmissions</a> and <a href="http://money.howstuffworks.com/money-laundering.htm">money laundering</a>.</p>
<p>Anyway, author Diane Dannenfeldt has written a lengthy article on How Paperless Offices Work, giving ample coverage to myriad aspects of the topic:</p>
<ul>
<li>Introduction to How Paperless Offices Work</li>
<li>Benefits of a Paperless Office</li>
<li>Transitioning to a Paperless Office</li>
<li>Managing Digital Documents</li>
<li>Going Paperless at Home</li>
<li>Paperless Office Solutions</li>
</ul>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Introduction to HoPaperless Offices Work</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Benefits of a Paperless Office</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Transitioning to a Paperless Office</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Managing Digital Documents</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Going Paperless at Home</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Paperless Office Solutions</div>
<p>Take a look at the full article here: <a href="http://communication.howstuffworks.com/how-paperless-offices-work.htm">How Paperless Offices Work</a> (howstuffworks.com)</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2009/07/03/howstuffworks-%e2%80%94-how-paperless-offices-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDF is green tech for your office</title>
		<link>http://paperjammed.com/2009/06/22/pdf-is-green-tech-for-your-office/</link>
		<comments>http://paperjammed.com/2009/06/22/pdf-is-green-tech-for-your-office/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 02:48:41 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Green Living]]></category>
		<category><![CDATA[Paperless Life]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Good Sites]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Printing]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=591</guid>
		<description><![CDATA[The basic tool required to bridge the gap between the carbon-intensive paper document present and the greener electronic document future was invented in 1993 as a way to streamline communications between publishers and printers. Today, the humble PDF file is the file format of choice for &#8220;final&#8221; electronic documents. Properly created and deployed, PDF alone [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<p>The basic tool required to bridge the gap between the carbon-intensive paper document present and the greener electronic document future was invented in 1993 as a way to streamline communications between publishers and printers.</p>
<p>Today, the humble PDF file is the file format of choice for &#8220;final&#8221; electronic documents. Properly created and deployed, PDF alone serves a critical need in reducing both business costs and environmental impacts.</p></blockquote>
<p>Duff Johnson of <a href="http://www.planetpdf.com">Planet PDF</a> wrote an article about two of my favorite topics: PDF Documents and Paperless Offices.</p>
<p>In the article, he discusses several key motivating factors for fitting PDF into your own workflow, with the underlying goal of making your office a little bit greener.</p>
<p>Read it all here: <a href="http://www.planetpdf.com/enterprise/article.asp?ContentID=PDF_is_green_tech_for_your_office&amp;page=0">PDF is green tech for your office</a></p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2009/06/22/pdf-is-green-tech-for-your-office/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Face it—Your great CD Collection Ripping Project is never going to end!</title>
		<link>http://paperjammed.com/2009/05/03/your-great-cd-collection-ripping-project-is-never-going-to-end/</link>
		<comments>http://paperjammed.com/2009/05/03/your-great-cd-collection-ripping-project-is-never-going-to-end/#comments</comments>
		<pubDate>Mon, 04 May 2009 01:44:49 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Paperless Life]]></category>
		<category><![CDATA[Scanning]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Media]]></category>
		<category><![CDATA[Organization]]></category>
		<category><![CDATA[Ripping]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=524</guid>
		<description><![CDATA[This afternoon was kind of lazy and rainy, and I found myself sifting through stacks of CD cases again, full of enthusiasm as I discovered some lost Rolling Stones and David Bowie albums, imagining how few discs remained before I could declare victory. But then I stumbled across a huge cache of classical music discs [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-527" src="http://paperjammed.com/wp-content/uploads/2009/05/istock_000008144609xsmall-200x300.jpg" alt="" width="200" height="300" />This afternoon was kind of lazy and rainy, and I found myself sifting through stacks of CD cases again, full of enthusiasm as I discovered some lost Rolling Stones and David Bowie albums, imagining how few discs remained before I could declare victory. But then I stumbled across a huge cache of classical music discs which immediately dampened my spirits, because these are usually the kind that come up as &#8220;Unknown Disc/Unknown Artist&#8221; when you try to download the titles. And there were loads of them.</p>
<p>Here are a few thoughts I have to share on these great media library projects. Not only are they never-ending, but the longevity of the task should guide some key decisions you make as you plod along.<span id="more-524"></span></p>
<p><strong>Accept that it&#8217;s Never Going to End</strong></p>
<p>I currently have ongoing projects to scan in every scrap of paper in my house, rip every CD to MP3, and scan in every pre-digital-era photograph. But the corpus is just too large. And I haven&#8217;t even considered ripping video; I have accepted that a full digital video library is a little too ambitious for me these days.</p>
<p>We need to be aware of this from the very beginning; if you feel like you bit off more than you can chew, you are normal.</p>
<p><strong>Never Give Up</strong></p>
<p>Try to keep your goals clear, so that you don&#8217;t lose steam and give up. Perhaps you are looking forward to being able to place the plastic boxes all in storage. Perhaps you can&#8217;t wait to be able to make those uber party mixes from your rich collection. In any case, every hour you spend doing the drudgery of ripping CDs brings you a little closer to these goals.</p>
<p><strong>Prioritize Your Work</strong></p>
<p>It is a whole lot better to spend your first days ripping your favorite music to MP3 than to be ripping some weird CDs your roommate left behind in college. Today I happily skipped over the Talking Heads CDs that I inherited from my brother—those don&#8217;t really need to be in my iTunes library, do they?</p>
<p><strong>Keep it Simple</strong></p>
<p>Make your work flow as simple as possible. You may still be doing this in three years—don&#8217;t over complicate things.</p>
<p>I have been working on my own collection for the past three years. When I first started, I was ripping the music on a PC using a tool called <a href="http://cdexos.sourceforge.net/?q=screenshots">cdex</a> to rip the MP3s and another tool called <a href="http://www.mp3tag.de/en/">Mp3tag</a> to edit the tags. These days I use <a href="http://www.apple.com/itunes/">iTunes</a> on my Mac to do both of these tasks. If I had some really fancy work flow going, it might not have been so easy to change machines. By keeping things simple, I was able to do exactly the same thing today that I did three years ago.</p>
<p><strong>Choose Good Settings</strong></p>
<p>&#8230;for your software. You don&#8217;t want to have to do this again, do you? And don&#8217;t go cheap on the bit rate, if you have the space.</p>
<p>In addition, you will probably want to decide between the convenience of a universal format versus the power of a proprietary or niche format. In my example, I opted to use MP3 for all of my music instead of some of the other, more powerful, formats available. I was stung once by the switch from PC to Mac where the handful of CDs that I had ripped to .wmf files were no longer usable.</p>
<p>If you are ripping <em>everything</em> to some killer lossless format, be sure you are looking far down the road and considering compatibility issues.</p>
<p><strong>Back it up!</strong></p>
<p>Make sure your <a href="http://paperjammed.com/2009/01/29/backup-your-life/">backup process</a> is ready for the increased load. If your backups consist of burning DVDs (or worse, CDs) of your data, you will very quickly tire of this, and you may just abandon one of the most important parts of your work flow. Oh, and remember, <a href="http://paperjammed.com/2009/02/19/if-there-arent-two-copies-in-separate-places-it-isnt-a-backup/">if there aren&#8217;t two copies in separate places, it isn&#8217;t a backup</a>.</p>
<p>A couple of months ago <a href="http://paperjammed.com/2009/02/27/one-step-closer-to-sleeping-well-at-night/">I bought two of those nice pocket-size portable hard drives</a>, and I always leave one at the office and I swap them once per week. This works for me: they are 320GB hard drives, providing plenty of room for all of my thousands of scanned documents, tens of thousands of photographs, and many thousands of MP3s, with plenty of elbow room.</p>
<p>When ripping a CD collection, the data risk is lower since you still retain the original CDs, but it still is a lot of work to rip them all. Don&#8217;t overlook the backup, or you will cry when the hard drive crashes.</p>
<p><strong>Know Where You Have Been</strong></p>
<p><strong></strong>Come up with a simple &#8220;bread crumb&#8221; mechanism to know where you have already been. You want to be able to quickly identify the music CDs you already ripped, without having to bring up iTunes every time. Keep the three year horizon in mind, so you choose a technique that will not be mysterious to you after some time passes (Hmmmm&#8230;. did I dog ear the corner of the CD insert to mark it? Where did I put that notebook where I wrote them down?)</p>
<p>I chose simplicity: I have one of those nice metallic Sharpie markers, the silvery kind. I put a small dot on the hub of each CD after I ripped it, just above the center hole. This way, several years from now, I should easily be able to spot the CDs that haven&#8217;t been introduced to my digital library.</p>
<p>I do this with photographs as well. As I scan them, I put a small marker dot on the back of each photograph, in the corner.</p>
<p><strong>Finally, Enjoy Your Music!</strong></p>
<p>I am quite capable of getting all wrapped up in the process for the sake of the process. Don&#8217;t forget to actually listen to the music you ripped!</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2009/05/03/your-great-cd-collection-ripping-project-is-never-going-to-end/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smooth out the bumps in your workflow with desktop scripting tools</title>
		<link>http://paperjammed.com/2009/03/10/smooth-out-the-bumps-in-your-workflow-with-desktop-scripting-tools/</link>
		<comments>http://paperjammed.com/2009/03/10/smooth-out-the-bumps-in-your-workflow-with-desktop-scripting-tools/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 02:06:05 +0000</pubDate>
		<dc:creator>Tad</dc:creator>
				<category><![CDATA[Scanning]]></category>
		<category><![CDATA[Searching and Indexing]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tools of the Trade]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://paperjammed.com/?p=339</guid>
		<description><![CDATA[Work flow is inherent in the kind of work that we do when scanning, indexing, searching, filing, tagging, and backing up all of our documents, photos, music, and video. Once you are committed to digital media, you will find that you often need to cobble together different programs in order to do away with some of the tedious manual labor.]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-340" src="http://paperjammed.com/wp-content/uploads/2009/03/istock_000004776175xsmall.jpg" alt="" width="341" height="226" />I love new software—when I order something new, such as the latest iLife suite, I eagerly check the UPS website to see if the package has been delivered, and I race home to try it out.</p>
<p>Of course, it is only a matter of days, or even hours, before the new glow has worn off and I begin to grouse about the things I wish they had done and I grumble about the nit-picky little bugs that are always there.</p>
<p>Even when the program works perfectly, we often want to use it in a work flow, using each program for what it does best.</p>
<p>Work flow is inherent in the kind of work that we do when scanning, indexing, searching, filing, tagging, and backing up all of our documents, photos, music, and video. Once you are committed to digital media, you will find that you often need to cobble together different programs in order to do away with some of the tedious manual labor.</p>
<p>Scripting tools can be as simple as macro recorders, as fancy as drag-and-drop pipelining tools, and as complex as full programming languages. Choose one that fits you and use it to bridge the gaps in your work flow.<span id="more-339"></span></p>
<p><strong>An Example</strong></p>
<p>I have never had a harsh thought about my sheet-fed scanner, the venerable <a href="http://www.fujitsu.com/us/services/computing/peripherals/scanners/scansnap/s510m.html">ScanSnap S510m</a>. But one thing has always annoyed me about the software package they provide: you can’t start scanning a new document until the OCR process is complete on the first.</p>
<p>What happens is this: you scan in a document; ScanSnap Manager receives it as a PDF and immediately passes it to Abbyy FineReader for OCR. All is good at this point.</p>
<p>But, the OCR process can take anywhere from 10 seconds to a few minutes, and if you were to scan in another document, FineReader complains:</p>
<p><img class="alignnone size-full wp-image-341" src="http://paperjammed.com/wp-content/uploads/2009/03/20090310-finereader.gif" alt="" width="434" height="199" /></p>
<p>This is where a little bit of AppleScript magic smoothed over this minor work flow annoyance.</p>
<p>I found that you can attach a bit of AppleScript as a “folder action” to a folder, and when a file appears in that folder, your AppleScript gets called. All I needed to do was figure out a way to get AppleScript to do the following:</p>
<ul>
<li>Wake up when a file appears</li>
<li>Grab the first unprocessed PDF file</li>
<li>Tell FineReader to start up, if it isn&#8217;t running</li>
<li>Tell FineReader to open the file</li>
<li>Wait for the processing to finish</li>
<li>Go back to step 2 until all files are done.</li>
</ul>
<p>It wasn’t exactly trivial—FineReader doesn’t actually have any special AppleScript support built in. But after a few experiments (i.e. a full weekend of fussing around) it was working smoothly.</p>
<p>Now I can scan as many documents as I want, knowing that OCR is happening at its own pace in a totally different flow.</p>
<p>Some day, when I have cleaned up the embarrassing bits of the code, I will share it here for fellow ScanSnap users.</p>
<p><strong>What scripting tools are out there</strong></p>
<p>The automation tools you use will depend on what software you are working with and what operating system you are using. On the Macintosh side, AppleScript and Automator will probably cover the bases. Things aren’t so pretty on the Windows side, but if you are willing to get a little dirty, Windows scripting can work miracles.</p>
<p>Whatever tool you use, I recommend finding as many simple examples on the Web as you can and running them and tweaking them slightly until you make them do what you want.</p>
<p>I am not an AppleScript programmer; I simply downloaded other people’s sample scripts that did file manipulations and poked and prodded them into shape.</p>
<p><strong>AppleScript</strong></p>
<p>In the Macintosh world, the old standby has always been AppleScript, with its quirky syntax that attempts to look like English. It is surprisingly easy to do some fairly heavy lifting with a minimal of effort.</p>
<p>In fact, though I find its syntax challenging and condescending at the same time, I heartily recommend AppleScript. The key is that Apple has built in AppleScript support to most of the main Macintosh applications.</p>
<p>For a taste of what AppleScript can do, here’s a whole mess of <a href="http://dougscripts.com/itunes/">cool scripts for automating iTunes</a>.</p>
<p>Imagine running a script that builds playlists for you or tags files automatically or finds duplicates and marks them.</p>
<p>This is the main <a href="http://www.apple.com/applescript/">AppleScript site</a>, and here&#8217;s a <a href="http://www.apple.com/applescript/firsttutorial/index.html">tutorial from Apple</a>.</p>
<p><strong>Automator</strong></p>
<p>Another Macintosh product, that provides a more graphical approach to hooking your apps together, is Automator. Here is an article that gives <a href="http://www.macdevcenter.com/pub/a/mac/2005/09/06/what-is-automator.html?CMP=OTC-13IV03560550">a good overview of the tool</a>.</p>
<p>This is what a simple work flow looks like in designer mode:</p>
<p><img class="alignnone size-full wp-image-343" src="http://paperjammed.com/wp-content/uploads/2009/03/20090310-automator.gif" alt="" width="555" height="375" /></p>
<p>You can see more or less what is going on here: You use a predefined set of actions, on the left side, to build up a pipeline on the right side.</p>
<p>In this case, the new automation action will get the selected documents, sort them, combine them into one PDF document, and then open that document in a PDF viewer.</p>
<p>I have always been a little confused with the utility of this product: it’s great if your application provides Automator actions, but what do you do if your app is like FineReader, with no special hooks built in?</p>
<p>Nevertheless, with Automator, you can do some pretty fancy things with many common tasks such as file management, email, and browsing. And there are plenty of custom Automator actions out there for the downloading.</p>
<p>Both Automator and AppleScript are Macintosh OS X built-ins.</p>
<p>For the serious Mac user, there is Bash Unix shell scripting, but that’s all I’m going to say about that. It’s there if you want it!</p>
<p><strong>Windows Scripting</strong></p>
<p>Things are somewhat different on the Windows side.</p>
<p>On the positive side, I believe that Microsoft’s <a href="http://www.microsoft.com/com/default.mspx">COM object architecture</a> makes it possible to script some pretty fancy things using off-the-shelf software.</p>
<p>In addition, the Office suite has amazing macro facilities that have been used by many as a full programming language, as the core of many successful commercial products.</p>
<p>But Windows just doesn’t seem to have anything analogous to AppleScript for gluing things together without getting your hands too dirty.</p>
<p>As a trivial example of the power of the Windows COM architecture, this <a href="http://cwashington.netreach.net/depo/view.asp?Index=142">short script</a> will launch Excel, create a fresh spreadsheet, and automatically feed in some data. To try it out, save the script to your desktop and double click it.</p>
<p>This is what I saw on my machine when I ran the script:</p>
<p><img class="alignnone size-full wp-image-344" src="http://paperjammed.com/wp-content/uploads/2009/03/20090310-excel-spreadsheet.gif" alt="" width="520" height="226" /><br />
Just like AppleScript on the Macintosh side, many Windows applications provide hooks for scripting.</p>
<p>The down side is that the scripting language is much more like a programming language, so it’s more comparable to writing shell scripts than to using a drag-and-drop automation tool like Automator.</p>
<p>But when you do the same thing over and over every day, it may be worth it to roll up your sleeves and get down and dirty with some VBScript.</p>
<p>An added benefit of this approach is that the language shares much of its functionality with Visual Basic for Applications, found in Word and Excel macros. If you are writing standalone Windows scripts, you can also write very complex Word and Excel macros. You also have the ability to do much of the same application automation within Word/Excel macros.</p>
<p><strong>AutoIT</strong></p>
<p>This is a freeware tool that many use for scripting their applications.</p>
<p>From the <a href="http://www.autoitscript.com/autoit3/">product website</a>:</p>
<ul>
<li>Easy to learn BASIC-like syntax</li>
<li>Simulate keystrokes and mouse movements</li>
<li>Manipulate windows and processes</li>
<li>Interact with all standard windows controls</li>
<li>Scripts can be compiled into standalone executables</li>
<li>Create Graphical User Interfaces (GUIs)</li>
</ul>
<p>What more could you ask for?</p>
<p><strong>Closing Thoughts</strong></p>
<p>There are other tools out there; don’t be afraid to check them out and try some of the examples. If you can automate just one annoying task that you do every day, it may be worth the hassle of spending a weekend writing the script.</p>
<p><strong>Epilogue</strong></p>
<p>Yesterday at work I finally rolled up my sleeves at work to tackle a nagging document problem that had been lingering for months.</p>
<p>We have a large quantity of PowerPoint slide decks that have critical company information embedded within. I work in the pharmaceutical industry, so many of those PowerPoint slides had chemical structures for various drug molecules embedded within as OLE objects.</p>
<p>The problem was that we wanted to extract that knowledge (the molecule files) electronically and text mine the slides, but our tools did not support PowerPoint. They did, however, support Microsoft Word.</p>
<p>How could I convert the slides to Word documents? There are dozens of ways on the Net to go in the other direction, but the only way to do what I wanted resulted in the OLE objects being converted to pictures—no good for my purpose. I did find that a copy/paste of each molecule from PowerPoint to Word worked correctly, but who wants to do that by hand with hundreds of documents?</p>
<p>After weeks of trying to find a real Microsoft developer at work to do the task, I finally gave in and tried my hand using VBScript and the Windows Scripting Host. In four hours I had the basics of a script going.</p>
<p>My simple VBScript file does the following:</p>
<ul>
<li>Prompt the user for a PowerPoint file and target directory</li>
<li>Launch PowerPoint and Word in the background</li>
<li>Loop through every slide, inspecting any OLE objects found within to see if it was created by ChemDraw or IsisBase Sketch, two common chemistry editor tools</li>
<li>If any such molecules are found, the following happens:
<ul>
<li>All of the &#8220;shapes&#8221; on the slide are copied to the clipboard</li>
<li>A new Word document is created with &#8220;Slide (1..n)&#8221; appended to the file name</li>
<li>The clipboard contents are pasted into the document</li>
</ul>
</li>
</ul>
<p>Sure, there are plenty of warts to work out, but I was happy to be able to run my script and watch as it magically consumed huge slide decks and spit out Word documents containing the exact data I was looking for. Windows Scripting Host is a powerful tool, as good as, if not better than AppleScript.</p>
<p>[Update: Added epilogue singing the joys of Windows Scripting Host]</p>
]]></content:encoded>
			<wfw:commentRss>http://paperjammed.com/2009/03/10/smooth-out-the-bumps-in-your-workflow-with-desktop-scripting-tools/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

