Skip navigation.

Harold's Home

   Home
  
XML version of this site

PHP Scripts

Index
CLI fun
Mail on 404
HB-NS (NewsScript)

Downloads

Applescripts
APOD to Desktop
Dreamweaver Extensions

Stuff

Writings
Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Bananas
Strippers
Sample Movies

News

Films seen this year (number of)
We saw The Ladykillers today and while eating an excellent dinner at an Italian restaurant before we were wondering how many movies we've been to this year, and whether we've seen one every week on average.
As I have an iCal calendar which lists all the movies I've seen this year and I'm learning AppleScript I boasted that this information could probably be extracted via AppleScript.

Turns out I'm right:

tell application "iCal"
    set mydate to date "01-01-2004"
    tell calendar 2
        -- calendar number 2 is the films calendar, it contains entries for all the films I've been to this year
        set theStuff to count (get events whose start date is greater than or equal to mydate)
        display dialog "Number of films seen this year: " & theStuff
    end tell
end tell


Open this script in a new Script Editor window.

I saw 24 movies this year in the cinema this year. I wasn't at every movie the group went to but overall this evens out with the others methinks.

There's a couple of caveats I should add to the script above:
- I can extract the count of the number of events as this calendar lists only movies, therefore there is no pollution.
- I have four calendars: one for private appointments, one for movies I've been to, one for work and one for birthdays. The movies calendar is number two in the list hence the reference to the number two in the script.
- I have no idea of the syntax to get the names of the events, so I cannot extract the movietitles so far.
- This script was formatted using the utility "Convert Script to Markup Code" from Jon's Little Page of AppleScripts. If you're reading this in an aggregator such as BlogLines or NetNewsWire you're missing out on the syntax coloring (no big deal really, but just so you know).
- If you're using a Mac click the link to the script to open a new script editor window with the script.
- On compiling the code the script editor will replace 01-01-2004 with a local date-formatted string, here's what I see: set mydate to date "donderdag, 01 januari 2004 00:00:00".
screensot of final script



[Update 09-07-2004 03:37] I've figured it out. Here's the new and improved code:

tell application "iCal"
    set mydate to date "01-01-2004"
    tell calendar 2
        set theStuff to count (get events whose start date is greater than or equal to mydate)
        set theList to get events whose start date is greater than or equal to mydate
        set allFilms to {}
        set end of allFilms to "Films seen this year: " & theStuff & return & return
        repeat with aName in theList
            set end of allFilms to get summary of aName & return
        end repeat
        display dialog allFilms as string buttons "OK" default button "OK"
    end tell
end tell


Open this script in a new Script Editor window.

Show all items | Read all items

About, copyright, privacy and accessibility | Mail