<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>lab.naoki.sato.name &#187; applescript</title>
	<atom:link href="http://naoki.sato.name/lab/archives/tag/applescript/feed" rel="self" type="application/rss+xml" />
	<link>http://naoki.sato.name/lab</link>
	<description>lab for naoki.sato</description>
	<lastBuildDate>Sun, 20 Mar 2011 06:02:24 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://naoki.sato.name/lab/archives/tag/applescript/feed" />
		<item>
		<title>EvernoteのノートのタイトルをAppleScriptで一括変更する</title>
		<link>http://naoki.sato.name/lab/archives/261</link>
		<comments>http://naoki.sato.name/lab/archives/261#comments</comments>
		<pubDate>Sun, 20 Mar 2011 06:02:24 +0000</pubDate>
		<dc:creator>naoki</dc:creator>
				<category><![CDATA[applescript]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://naoki.sato.name/lab/?p=261</guid>
		<description><![CDATA[Brogtrottrというサービスがあります。
RSSの記事をメールとして送信してくれるサービスです。
個人的に、このサービスをGoogle Readerと組み合わせて利用しています。
具体的には、Google Read [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogtrottr.com/">Brogtrottr</a>というサービスがあります。<br />
RSSの記事をメールとして送信してくれるサービスです。</p>
<p>個人的に、このサービスをGoogle Readerと組み合わせて利用しています。<br />
具体的には、Google Readerで気になった記事は共有するようにして、 共有アイテムのRSSをBrogtrottrでEvernoteに送信し、気になった記事がEvernoteに自動的にクリッピングされるようにしています。</p>
<p>ただ1点、Brogtrottrが残念なのが、メールのタイトルが変更できないという点。<br />
Brogtrottrからのメールのタイトルは&#8221;サイト名: タイトル&#8221;のようになり、Google Readerの共有アイテムのようにサイト名が長いと、Evernoteに登録した際非常に冗長になってしまいます。</p>
<p>幸い、Mac版のEvernoteではAppleScriptでノートのタイトルが変更できます。</p>
<p>ということで、冗長なタイトルになっているノートを一括して変更するAppleScriptをさっくり書いたので、メモとしてあげておきます。</p>
<p>なお、AppleScript中の&#8221;switchText&#8221;は<a href="http://macscripter.net/viewtopic.php?id=13008">こちら</a>から引用させていただきました。<br />
感謝です。</p>
<p><span id="more-261"></span>※実際に使う際は、最初のpropertyの値を変更のこと。</p>
<blockquote>
<pre>property nb : "_inbox" -- ノートブック名
property str_G_orig : "naoki's shared items in Google Reader" -- 置換え対象文字列
property str_G_sub : "G" -- 置換え後文字列

tell application "Evernote"
	-- repeat with var_note in (get selection) -- 選択しているノート
	repeat with var_note in (get notes in notebook nb) -- ノートブック内の全ノート
		set var_title to (get title of var_note)
		if var_title contains str_G_orig then
			set var_title_new to (switchText from var_title to str_G_sub instead of str_G_orig) of me
			set title of var_note to var_title_new
		end if
	end repeat
end tell

to switchText from t to r instead of s
	set d to text item delimiters
	set text item delimiters to s
	set t to t's text items
	set text item delimiters to r
	tell t to set t to item 1 &amp; ({""} &amp; rest)
	set text item delimiters to d
	t
end switchText</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://naoki.sato.name/lab/archives/261/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://naoki.sato.name/lab/archives/261" />
	</item>
		<item>
		<title>ScanSnapから作成した連番画像ファイルを1クリック(+α)でePubに変換する -Mac編-</title>
		<link>http://naoki.sato.name/lab/archives/153</link>
		<comments>http://naoki.sato.name/lab/archives/153#comments</comments>
		<pubDate>Mon, 05 Apr 2010 13:42:34 +0000</pubDate>
		<dc:creator>naoki</dc:creator>
				<category><![CDATA[ebooks]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[epub]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://naoki.sato.name/lab/?p=153</guid>
		<description><![CDATA[先日の連番画像ファイルからePubを作成するの続きです。
先日の記事ではePubを作成するシェルスクリプトを公開しましたが、いちいちターミナルからスクリプトを実行するのも面倒なので、AppleScriptを使ってFind [...]]]></description>
			<content:encoded><![CDATA[<p>先日の<a href="http://naoki.sato.name/lab/archives/142">連番画像ファイルからePubを作成する</a>の続きです。</p>
<p>先日の記事ではePubを作成するシェルスクリプトを公開しましたが、いちいちターミナルからスクリプトを実行するのも面倒なので、AppleScriptを使ってFinderからスクリプトを呼出し、Finderで開いているフォルダ内の連番画像をePubに変換するアプリケーションを用意しました。AppleScriptですので、Mac専用です。</p>
<p><a href="http://naoki.sato.name/epubunco/epubsh.dmg">連番画像ファイル-&gt;ePub作成アプリケーション</a></p>
<p>簡単な使い方は以下の通り。なお、未検証ですが連番画像のファイル名に日本語が含まれていると上手くいかないかも知れませんので、ファイル名は英数字のみにしておいた方が無難だと思います。</p>
<ol>
<li>自分のホームディレクトリに &#8220;bin&#8221; フォルダを作成します。</li>
<li>dmgに入っている &#8220;epubsh.sh&#8221; を1.で作成した &#8220;bin&#8221; フォルダにコピーします。</li>
<li>dmgに入っている &#8220;epubsh.app&#8221; を任意の場所 (&#8220;bin&#8221; や &#8220;アプリケーション&#8221; をおすすめします) にコピーし、DockもしくはFinderのツールバーに登録します。</li>
<li>ePubに変換したい一連の画像のあるディレクトリを最前面のFinderで開いた状態にし、3.で登録した &#8220;epubsh.sh&#8221; を実行します。</li>
<li>タイトル、著者を入力するダイアログが表示されるので、それらを入力します。</li>
<li>暫く待つと、画像と同じディレクトリに &#8220;タイトル.epub&#8221; という名前でePubファイルが作成されます。</li>
</ol>
<p>以上です。いつも通り検証不十分ですので、At Your Own Riskでお願いします。コメント等々ございましたら<a href="http://twitter.com/naokisatoname">@naokisatoname</a>宛に頂けると幸いです。</p>
<p>以下、スクリーンショット付きの詳細説明とスクリプトのソース。</p>
<p><span id="more-153"></span></p>
<h3>詳細設定手順</h3>
<p>ここでは、以前ScanSnapからPDF形式で電子化し、今回検証のためにjpgで画像を抽出した<a href="http://www.amazon.co.jp/gp/product/4840120722?ie=UTF8&amp;tag=naokisatoname-22&amp;linkCode=as2&amp;camp=247&amp;creative=7399&amp;creativeASIN=4840120722">新海誠さんの小説・秒速5センチメートル</a>を使用しています(連番画像ファイル名は &#8220;5cm_xxx.jpg&#8221;)。</p>
<ol>
<li>上のリンクから<a href="http://naoki.sato.name/epubunco/epubsh.dmg">dmgファイル</a>をダウンロードします。</li>
<li>Finder上でダブルクリックし、マウントします。</li>
<li>中に &#8220;epubsh.app&#8221; と &#8220;epubsh.sh&#8221; の2ファイルが入っていることを確認します。</li>
<li>自分のホームディレクトリに &#8220;bin&#8221; フォルダを作成します。</li>
<li>dmgに入っている &#8220;epubsh.app&#8221; と &#8220;epubsh.sh&#8221; を &#8220;bin&#8221; フォルダにコピーします。<br />
<a href="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_1.png"><img src="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_1-300x169.png" title="20100405_1" width="300" height="169" class="alignnone size-medium wp-image-146" /></a></li>
<li>&#8220;epubsh.app&#8221; をDockもしくはFinderのツールバーに登録します。個人的にはFinderのツールバーの方が使い易い気がします。<br />
<a href="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_2.jpg"><img src="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_2-300x68.jpg" title="20100405_2" width="300" height="68" class="alignnone size-medium wp-image-147" /></a></li>
<li>連番画像ファイルをおいたディレクトリをFinderで表示します。<br />
<a href="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_3.png"><img src="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_3-300x169.png" title="20100405_3" width="300" height="169" class="alignnone size-medium wp-image-148" /></a></li>
<li>先ほど登録した &#8220;epubsh.app&#8221; をクリックして実行します。</li>
<li><em>Book Title:</em> というダイアログが表示されるので、本のタイトルを入力します。<br />
<a href="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_4.png"><img src="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_4-300x124.png" title="20100405_4" width="300" height="124" class="alignnone size-medium wp-image-154" /></a></li>
<li><em>Book Author:</em> というダイアログが表示されるので、本の著者を入力します。<br />
<a href="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_5.png"><img src="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_5-300x124.png" title="20100405_5" width="300" height="124" class="alignnone size-medium wp-image-155" /></a></li>
<li>OKをクリックして暫く待つと、Finderで開いていた、画像と同じディレクトリに &#8220;タイトル.epub&#8221; というePub形式のファイルが作成されます。<br />
<a href="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_6.png"><img src="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_6-300x169.png" title="20100405_6" width="300" height="169" class="alignnone size-medium wp-image-151" /></a></li>
<li>後はePubを表示して読書を楽しみましょう。<br />
<a href="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_7.png"><img src="http://naoki.sato.name/lab/wp-content/uploads/2010/04/20100405_7-300x198.png" title="20100405_7" width="300" height="198" class="alignnone size-medium wp-image-152" /></a></li>
</ol>
<h3>ソースファイル</h3>
<p>AppleScriptおよびsh Scriptのソースです。基本的にdmgファイルの内容と同様です。ダウンロードが上手くいかない際は、右クリックでファイル名を指定して保存して下さい。</p>
<ul>
<li><a href="http://naoki.sato.name/epubunco/epubsh.scpt">AppleScript (2.6KB)</a></li>
<li><a href="http://naoki.sato.name/epubunco/epubsh.sh">sh Script (3.3KB)</a></li>
</ul>
<p>知識のある方、改変・修正はご自由に。その際は後学のため<a href="http://twitter.com/naokisatoname">@naokisatoname</a>までご連絡いただければ幸いです。</p>
<h4><span style="color: #ff6600;">※2010/04/08追記</span></h4>
<p>公開したスクリプトにバクがあったので、dmg、ソースとも置き換えました。</p>
<p>タイトルやパスにスペースが含まれていた際に正常に動作しない現象を修正しました。</p>
<h4><span style="color: #ff6600;">※ 2010/04/26追記</span></h4>
<p>dmg、ソースを再度置き換えました。</p>
<p>前回と同じく、タイトルやパスにスペースが含まれていた際に正常に動作しない不具合の修正です。</p>
<p><span style="color: #808080;">スクリプト内でディレクトリ名をクォートするのを忘れておりました。スミマセン…</span></p>
<h4><span style="color: #ff6600;">※  2010/05/09追記</span></h4>
<p>dmg、ソースを置き換えました。</p>
<p>作成されたePubがAppleのiBooksで開けないバグを修正しました。</p>
<p>ただし、iBooksでは画像のサイズを変更する指定が無効になるらしく、表示が崩れる可能性があります。</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;"><a href="../../epubunco/epubsh.sh">連番画像ファイル-&gt;ePub作成ス クリプト</a></div>
]]></content:encoded>
			<wfw:commentRss>http://naoki.sato.name/lab/archives/153/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://naoki.sato.name/lab/archives/153" />
	</item>
	</channel>
</rss>

