AppleScript


I have a fairly large address book.488 contacts, who are shared between my various hobbies and pastimes. Including a large number of people who are related to one another. In some of these cases, I have populated the Related Names field, often where I just need to know a child’s parents names, but also in other cases where the related person is also in my address book.

I have several groups of people who are siblings, and I could go through each sibling and add in ‘father, mother, sister, brother’ items for each sibling, but it would be great if this could be done automatically.

The father/mother bit should be relatively straightforward, since the fields are the same:

Bob and Alice have two children, Carol and David. If I have put father:Bob and mother:Alice in for Carol, and I put brother:David in, then the system should be able to easily put father:Bob and mother:Alice in for David.

The tricky bit is with gender related to siblings. There is no default field for gender in Address Book, so how does the system know if David should have sister:Carol or brother:Carol? Especially since I don’t want to have to hand-code a list of names and which gender they are. I have many people with unusual names, and some with non-gender-specific names.

A short-term solution might be to (a) see if there are other sibling relationships (ie, if there is also brother:Eric, and Eric has sister:Carol, then clearly Carol is a female, and David should also have sister:Carol); or (b) have a temporary sibling:Carol field, which can be changed by the user.

You could then have a Smart Address Book Group which has all people with a sibling: field, which would make finding those people easier.

Conceivably, this should be possible with AppleScript. I have, however, butted heads with Address Book’s scripting in the past. It doesn’t always seem to be that easy to get data from this application.

Perhaps this type of feature, as well as my other hope for Address Book (notice if two contacts have the same number, including just the last X digits (for +614 vs 04 numbers in Australia, which are the same), and allow manipulation of this data, might appear in Leopard.

View Comments (4)   RSS Feed for Comments on this Post

I’ve used Gmail/Calendar, and have just migrated my data back to iCal, since now I have a laptop it makes a bit more sense to have the data stored locally.

There is one thing I’d like to see possible in both systems is to mark a meeting attendee as attending. It only appears to be possible to do this from the person themselves. Sometimes I speak to an attendee of a function, and they are coming, but the email or calendar system they are using does not integrate well with iCal/gCal, so the email is sent back, and I need to modify stuff manually.

Google Calendar at least allows you to add “Guests”, something I haven’t yet figured out how to do with iCal.

However, with iCal, it appears to be possible to script iCal, so I may be able to add this functionality.

View Comment (1)   RSS Feed for Comments on this Post

bash:

mdls filename | grep FinderComment

AppleScript:

tell application "Finder"
    comment of file
end tell

python:

#!/usr/bin/pythonw
from appscript import *
path = '/Users/NAME/your/path/here'
comment = app('Finder').items[path.replace('/', ':')].comment.get()

View Comment (1)   RSS Feed for Comments on this Post

I use an AppleScript to implement “Open Terminal Here” functionality on my Macs, and just now I noticed on the Intel machine it had stopped working properly if Terminal wasn’t already running. For some reason, on PPC it still sends the message through, but on x86 it doesn’t.

So, I had to use the following code to get it to work if Terminal wasn’t already running, which can be generalised to any application:

repeat while "Terminal" is not in name of processes
    delay 0.5
end repeat

(more…)

View Comment (1)   RSS Feed for Comments on this Post

I’m currently rewriting iTunesRating to allow for half-star ratings.

This is a program that sits in the menubar, and displays the rating of the current song, and allows it to be changed.

I’ve learned a lot about how to create a NSStatusItem already tonight, and I’m working on getting the AppleScript interface to properly with it.  It builds a bit on iTunesRater, a program I wrote in AppleScript Studio, which allows for the same thing, although this will have a much smaller screen footprint.

If only I could get hold of the original source code - I could fix it in a few seconds, I suspect.

More updates later.

Arse Kickin’ Lady From The NorthwestTim Rogers And The Twin SetWhat Rhymes With Cars And Girls ★★★★½

View Comment (1)   RSS Feed for Comments on this Post

There are a few new things in AppleScript support for iTunes 7.

artwork:

downloaded (boolean, r/o) : was this artwork downloaded by iTunes?

playlist:

special kind (none/Audiobooks/folder/Movies/Music/Party Shuffle/Podcasts/Purchased Music/TV Shows/Videos, r/o) : special playlist kind

track:

episode ID (Unicode text) : the episode ID of the track
episode number (integer) : the episode number of the track
gapless (boolean) : is this track from a gapless album?
season number (integer) : the season number of the track
skipped count (integer) : number of times this track has been skipped
skipped date (date) : the date and time this track was last skipped
show (Unicode text) : the show name of the track
video kind (none/movie/music video/TV show) : kind of video track

Most of these are expected with the addition of the new features: gapless playback and TV/Movie support. At least now we can programmatically change the tags for TV shows.

There are two there that are quite interesting: skipped count/date. They are available as columns in the list views too, I just hadn’t noticed them yet. Now it will be possible to have smart playlist additions like: skipped count < 2.

View Comment (1)   RSS Feed for Comments on this Post

I’ve updated my Insert iTunes Data (HTML) script for generating a block of text that describes the current playing iTunes track.

This version links to the iTunes Music Store, rather than Google. It is relatively smart, in that the track name link also has the artist name, and the album name does too, as long as the album isn’t a compilation.

The only (slight) bug is that the track name seems to need to be just the way iTMS displays it, so having (Live) might stuff up a link. This might be only if there isn’t a Live version in the iTMS.

I Can’t Tell You Why (Live)EaglesHell Freezes Over ★★★★★

Code after the jump.
(more…)

View Comments (5)   RSS Feed for Comments on this Post

I googled for HTMLify Applescript, wanting to find out some simple code for how to escape the text in an AppleScript string, so I can pass it as arguments to a URL.

My site came up with the top link. I was hoping for a better solution to the one I had come up with!

View Comments (2)   RSS Feed for Comments on this Post

I’ve already written a small Automator application that will resize an image to 640×480, but what about if I want to change it to a different size. There’s no way to set the resize amount on the fly in Automator, so I thought, it should be easy to do it in AppleScript.

Except, for some reason, Preview.app isn’t scriptable.

I do have Image Events.app floating around (not sure if it’s a standard part of the system), which can do what I want.

tell application "Finder"
	set sels to selection
end tell

repeat with sel in sels
	tell application "Image Events"
		set img to open sel as alias
		set dims to dimensions of img
	end tell

	set cursize to "Current Size of Image: " & (first item of dims as integer as text) & " x " & (last item of dims as integer as text)

	display dialog cursize
end repeat

This gets the current size, but I’m yet to find an easy way to get input from the user, and resize it according to this. I’m sure it can’t be that tricky!

View Comments (3)   RSS Feed for Comments on this Post

Here’s a nice little AppleScript I knocked up to grab all of the details of my podcasts, for the previous post:

tell application "iTunes"
	set podcastList to {}
	repeat with trk in selection
		set thisPodcast to album of trk & " • " & artist of trk
		if thisPodcast is not in podcastList then
			set podcastList to podcastList & thisPodcast
		end if
	end repeat
end tell

set HTML to "<ul>"
repeat with trk in podcastList
	set HTML to HTML & "<li>" & trk & "</li>"
end repeat
set the clipboard to HTML & "</ul>"

Hot Toddy • MindtripChillout Sessions 8 ★★

View Comment (1)   RSS Feed for Comments on this Post

Next Page »