<?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>James Badger's Personal Site &#187; AppleScript</title>
	<atom:link href="http://jamesbadger.ca/category/development/applescript/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamesbadger.ca</link>
	<description></description>
	<lastBuildDate>Sat, 13 Jun 2009 23:59:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AppleScript</title>
		<link>http://jamesbadger.ca/2005/09/22/applescript/</link>
		<comments>http://jamesbadger.ca/2005/09/22/applescript/#comments</comments>
		<pubDate>Fri, 23 Sep 2005 03:37:01 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://www.jamesbadger.ca/?page_id=9</guid>
		<description><![CDATA[
Some beginner scripts for use in Apple&#8217;s Script Editor. If you&#8217;re just starting AppleScript, try figuring out what these scripts do and how they do it, then try running them to see if you were correct.


TextEdit Word Count

tell application "TextEdit"
	activate
	set _t to text of document 1
	set _num to (number of words of _t) as string
	display [...]]]></description>
			<content:encoded><![CDATA[<p>
Some beginner scripts for use in Apple&#8217;s Script Editor. If you&#8217;re just starting AppleScript, try figuring out what these scripts do and how they do it, then try running them to see if you were correct.</p>

<p>
<h3>TextEdit Word Count</h3>
<pre>
tell application "TextEdit"
	activate
	set _t to text of document 1
	set _num to (number of words of _t) as string
	display dialog (_num &#038; " words found")
end tell
</pre>
</p>
<p>
<h3>TextEdit Character Count</h3>
<pre>
tell application "TextEdit"
	activate
	set _t to text of document 1
	set _num to (number of characters of _t) as string
	set _list to (words of _t)
	set _num2 to 0
	repeat with i from 1 to (count of _list)
		set _item to item i of _list
		set _num2 to _num2 + (number of characters of _item)
	end repeat
	display dialog (_num &#038; " characters found," &#038; return &#038; _num2 &#038; " visible characters found")
end tell
</pre>
If you have the <a href="http://www.apple.com/applescript/scriptmenu/" title="Apple - Software - AppleScript - Script Menu">Script Menu Extra</a> activated, you can access these scripts directly from TextEdit. Here&#8217;s how. 
Open the above scripts in Script Editor, and save them to this folder (Your home folder will be different, of course):<br />
<img src="/wp-downloads/textedit-script.png" title="Save scripts to this folder" style="border: 1px solid #444;" /><br />
If one or more of these folders don&#8217;t already exist, you can create them with the Finder, or from within the Save Dialog Box in Script Editor.
</p>
<p>
<h3>Internet Beat Time</h3>
<pre>
set gmt_time to (time to GMT)
if gmt_time is less than 0 then
set gmt_time to -gmt_time
end if
set bmt_dif to gmt_time + 3600
--refresh beat time
set here_time to time of (current date)
set bmt_time to here_time + bmt_dif
if bmt_time is greater than or equal to 86400 then
set bmt_time to bmt_time - 86400
end if
set beat_time to (bmt_time div 86.4)
display dialog "Current Internet Time:" &#038; return &#038; (beat_time) &#038; " Beats"
</pre>
</p>
<p>
<h3>iTunes Selection Enumerator</h3>
<pre>
-- NOTE: BE VERY CAREFUL WITH THIS SCRIPT.
-- It is very easy to accidently rewrite tag info accidently,
-- and there is no undo. You use it at your own risk. For example,
-- you could accidently delete the track name of every song in 
-- your library, or any other field that can be modified
-- through the Info dialog in iTunes.

-- Runs a method of your choice on the selected iTunes songs

on run
	tell application "iTunes"
		
		set sel_list to selection of window 1
		
		
		repeat with i from 1 to (number of items of sel_list)
			set aSong to (item i of sel_list)
			-- aSong is one of the elements of the selection
			
			-- perform some modifications here, see iTunes AppleScript dictionary,
			-- at iTunes Suite -> track, to see what you could modify.
			
			-- an option would be to automatically remove ".mp3" from the filenames,
			-- like so:
			
			set thename to name of aSong
			
			set toReplace to ".mp3"
			set replaceWith to ""
			
			if (thename contains toReplace) then
				set OldDelims to AppleScript's text item delimiters
				set AppleScript's text item delimiters to toReplace
				set newText to text items of thename
				set AppleScript's text item delimiters to replaceWith
				set thename to newText as text
				set AppleScript's text item delimiters to OldDelims
				
				set name of aSong to thename
			end if
			
			-- other options could include setting 'shuffable', start/finish times,
			-- 'bookmarkable', played date, played count, lyrics, which cannot be
			-- modified by iTunes' Multiple Song Information window.
			
		end repeat
		
	end tell
	
end run
</pre>
</p>]]></content:encoded>
			<wfw:commentRss>http://jamesbadger.ca/2005/09/22/applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacker Translator</title>
		<link>http://jamesbadger.ca/2005/09/11/hacker-translator/</link>
		<comments>http://jamesbadger.ca/2005/09/11/hacker-translator/#comments</comments>
		<pubDate>Mon, 12 Sep 2005 03:27:07 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://www.jamesbadger.ca/?page_id=6</guid>
		<description><![CDATA[Version 1.15 &#8211; Sept 28/03

Hacker Translator will translate any text you input into &#8216;leet-speak&#8217;. The idea of &#8216;leet-speak&#8217; is to replace as many letters with numbers/symbols as possible.
Hacker Translator will also let you customize the translation process, by changing options such as enabling/disabling word translation, enabling/disabling character translation, specifying whether characters will translate into numbers [...]]]></description>
			<content:encoded><![CDATA[<p>Version 1.15 &#8211; Sept 28/03</p>

<p>Hacker Translator will translate any text you input into &#8216;leet-speak&#8217;. The idea of &#8216;leet-speak&#8217; is to replace as many letters with numbers/symbols as possible.<br />
Hacker Translator will also let you customize the translation process, by changing options such as enabling/disabling word translation, enabling/disabling character translation, specifying whether characters will translate into numbers or symbols or random. You can also translate &#8216;leet-speak&#8217; back into english, allowing you to decode cryptic H4X0R messages.</p>

<div class="download"><h4>Download</h4>
<a href="wp-downloads/ht115.dmg">Download Disk Image &#8211; 148 KiB</a><br />
<span class="small">MD5 (ht115.dmg) = d81e4b6dedc3280bafbcdb46355eba1d</span><br />
<a href="wp-downloads/ht115.sitx">Download SITX &#8211; 72 KiB</a><br />
<span class="small">MD5 (ht115.sitx) = a865e439b71b99962936dd77e7c53ede</span>
</div>

<h4>What&#8217;s New</h4>
<p>In version 1.15, you can specify which direction of translation you would like, and you can also randomize the character translation process via the preferences window.</p>

<h4>Requirements</h4>
<ul><li>A Macintosh</li>
<li>Mac OS X version 10.1.3 or newer</li>
</ul>
<h4>Cost</h4>
<p>Free!</p>

<h4>Known Issues</h4>
<p>None known.</p>]]></content:encoded>
			<wfw:commentRss>http://jamesbadger.ca/2005/09/11/hacker-translator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
