02.03.08

A fresh iPhone each morning

Posted in Apple, Media, Tech at 1 pm

I’ve got a couple of short podcasts that I’m subscribed to that are daily. Merriam Webster’s Word of the Day and Scientific American’s 60 Second Science are short little podcasts that are an interesting way to start my daily commute.

However, it’s bugged me that when I drop my iPhone into it’s cradle at night when I get home, it syncs up the podcasts at that time. This is anywhere from 6 to 11pm. However, the next day’s podcasts are not available until after midnight. In order to get the Word of the Day on the Day of the Word, I’ve been resorting to picking up my iPhone out of the cradle each morning as I’m rushing out the door and dropping it back in and then waiting for it to sync. Sometimes this is just a few seconds, but if one of my other longer podcasts subscriptions had an overnight update, it can take a few minutes.

It’s a small matter for modern living, but I figured there ought to be a better way. iTunes doesn’t have a native way of telling an iPod or iPhone to refresh at a certain time. There’s two times when the sync will start: If you hit the Sync button in iTunes and when iTunes first connects with the iPhone.

The sync button method is a no-go for me, because it A) requires me to do something and B) in order to do it, I need to have the screen turned on and the mouse ready to click.

But when I say “when iTunes first connects with the iPhone”, there are a multitude of ways that this could happen. It could be the time when I plug the iPhone in while iTunes is running. It could be when I restart the Mac and iTunes automatically launches and finds the iPhone connected. Or it could be whenever iTunes gets launched. All that needs to happen is for iTunes and iPhone to become disconnected and reconnected.

So what are my options? I could have the Mac on an outlet with a timer on it and force the Mac to power down and then start it back up again. I could set the Energy Saver preference pane to schedule a shutdown and startup of the Mac. I could build a contraption out of Legos that would lift the iPhone out of it’s cradle and then slam it back down again. I could have a similar contraption that pulls the USB cable out of the Mac and plugs it back in. I could put the USB hub on a timer at its power connection.

But far more simply, I could use AppleScript to tell iTunes to quit and then tell iTunes to run. The key is getting the said script to run at the appropriate time. The easiest way of doing that is to schedule an event in iCal and using the alarm function to trigger the script. So here we go…

1) In your Applications folder look for the AppleScript folder and then open the Script Editor.

2) Type the following lines:

tell app “iTunes” to quit
delay 30
tell app “iTunes” to run

3) Click the Compile button and you’ll see the code get nice and formatted, color coded even.

4) If you want to test it, click the Run button. iTunes will quit if it’s already running and then 30 seconds later it will re-launch.

5) Save the script and call it something obvious like “iPhone Refresh”. I saved it to the Documents folder, but you can save it anywhere. You don’t need to set any other options in the Save dialog box. The defaults are fine.

6) Open up iCal and double click on the time of day when you’d like the script to run. I set it up to run at 6am.

7) Set script to repeat daily.

8) Set the alarm to “Run script”.

9) Below the Run Script setting click and select “Other…” and then find the script file you just saved.

10) Set the “Minutes before” to zero.

That’s it. I found lots of other ways to specifically choose the “Sync iPhone name” menu item, but they were 5 to 10 times the amount of code and with no further advantages. My method will refresh any and all iPhones or iPods connected to the machine, it will disconnect anyone that is ‘sharing’ the iTunes library, and it will help stave off any memory leaks that iTunes might develop. These are unintended consequences, but in my situation, they’re all good ones.

Comments are closed.

RSS feed for comments on this post · TrackBack URL