Chibimagic's Weblog

Archive for December 2008

I was trying to write an applescript to manage my iTunes playlists. I have a manual playlist of the least recently added unwatched TV shows and episodes of TEDTalks, some of which are checked, and I sync this playlist to my iPhone. I wanted a script to remove watched tracks from this playlist and enable additional tracks if there’s space on my iPhone.

At first I was trying to loop through each track of the list, check its play count, and delete if necessary. Then I realized that if you delete track 1, tracks 2 through n become tracks 1 through n-1, and the next track to be processed is track 2. So tracks immediately following a played track would not get processed. Then I was trying to store the index of played tracks to a list, and every time I delete something, loop through the rest of the list and decrease its index by one. Then I started looking at example applescripts and realized there was a single line I could use to copy all played tracks to a list, but there didn’t seem to be a way to delete tracks from a playlist without using its index, which means we still have to deal with the original problem. And then I realized that what I really wanted to do was:

delete every track of playlist "* TV" whose played count > 0

That’s when I realized how backwards and sophisticated applescript is.

I tried to do handstands for you
I tried to do headstands for you
Everytime I fell you on yeah everytime I fell
I tried to do handstands for you
But everytime I fell for you
I’m permanently black and blue
Permanently blue for you

I’ll pile on the candy
It’s such a pretty sight
Makes the food taste dandy
But my tummy hurts all night

I’ll put in some ingredients
But keep the rest for me
I’m not just disobedient
I’m careful, can’t you see?

It’s a piece of cake to bake a pretty cake
If the way is hazy
You gotta do the cooking by the book
You know you can’t be lazy
Never use a messy recipe
The cake will end up crazy
If you do the cooking by the book
Then you’ll have a cake
We gotta have it made
You know that I love cake
Finally it’s time to make a cake

Making food is just like science
Will tools that blend and baste
And every fun appliance
Gives the food a different taste

It’s a piece of cake to bake a pretty cake
If the way is hazy
You gotta do the cooking by the book
You know you can’t be lazy
Never use a messy recipe
The cake will end up crazy
If you do the cooking by the book
Then you’ll have a cake
We gotta have it made
You know that I love cake
Finally it’s time to make a cake

We gotta have it made
You know that I love cake
Finally it’s time to make a
You gotta do the cooking by the book

Cooking by the Book from the LazyTown soundtrack. Via Tyson.