Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

vbs script for iTunes converted for use on Mac?

This guy wrote an awesome vbs script that will create an intervaled playlist for runners, where you can set your intervals — for example, run for five minutes, walk for 2 — and it will automatically truncate the songs in your playlist for you. It even puts a "ding" in between each interval so you know when it ends and you never have to consult your stopwatch again.

The problem? It only works on Windows! (boo!) I have never written an AppleScript before — would it be possible for someone to translate this file so it works on my Mac?

IBook, Mac OS X (10.4.5)

Posted on Mar 10, 2006 3:57 PM

Reply
Question marked as Best reply

Posted on Mar 10, 2006 4:19 PM

What's there to translate?

with timeout of 10000 seconds
tell application "iTunes"
play playlist "run" -- change to actual playlist name
delay (5 * minutes)
play playlist "walk" -- change to actual playlist name
delay (2 * minutes)
end tell
end timeout

[edit] :o) it's can get very complicated: see this http://hac.95mb.com/Techs.html, those two apps were written in AppleScript.
18 replies

Mar 11, 2006 6:22 PM in response to Brittanie Hoofard

Thanks, you're welcome to send out the link. Doug (of Doug's scripts that you linked to) might be interested in wrapping it up for distribution on his site. I'll post back if anything happens with that. Credit is due to the originator of the idea Jeff, and I only request my name/email be kept with the script throughout iteration, distribution, modification etc.

Mar 11, 2006 6:37 PM in response to Michael Henley

Cool. I email Jeff Welch and Lifehacker (who linked to Jeff's site originally) and made sure they understood you wrote the thing — I only asked for it. I'll email Doug too!

Just as a side note, I have decided to copy all the songs in my original workout playlist, then run the script on the duplicates, which will be truncated. The original songs will stay the same and then I won't have to run the second script anytime I want to hear the full song.

Thanks again Michael for all your help.

Mar 12, 2006 8:21 AM in response to Michael Henley

First of all, thanks to Brittanie, Michael, and everyone else who has helped whip this thing out. I only wish I had an apple so I could join in the fun.

Secondly, I wanted to fully explain what my VBScript does so that you make sure to cover everything in the Applescript. Here is some psuedo code

* Get a playlist name from the user.
* Get the interval pattern of the format h:m:s,h:m:s,...
* For each interval in the pattern
* Convert each interval to it's total number of seconds
* If that process throws an error, alert the user that their pattern is bad.
* Add the interval, as seconds, to a new array.
* End For

* Open iTunes and look for the given playlist, alert the user if the playlist could not be found.

* Get the transitional track (some track that plays before a break, less than a second long--in this case "Ding.mp3")

* Create a new playlist who's name is "*" + Original Playlist Name

* For each track in the playlist:
* Reset the start and finish to their original values
* Subtract the track's duration from the time left
* If that result is <= 0
* Set the track's finish time to be the difference.
* Get the next interval (if at the end, start over with the first interval)
* Set the Add Transtion Flag = True
* End If
* Add the track to the new runners playlist
* If Add Transition Flag = True, add the transition track to the new playlist.
* End For
* Alert "Finished".

And for the undo script:

* Get the original playlist name from the user
* Open iTunes and look for that playlist.
* If it could not be found, alert the user.
* For each track in the playlist
* Reset the start and finish to their original values
* End For

* Get the runner's playlist ("*" + Original playlist name).
* If it could not be found, alert the user.
* Delete the playlist.
* alert "Finished"<br>
Windows XP Pro

vbs script for iTunes converted for use on Mac?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.