I've had some experience in the past with AppleScript, and it seemed like it would tear this up. It took some time and research, but I eventually came up with this.
One hangup I had is that having a quotation mark in an AppleScript string is not supported in a way that I'd like as a programmer of more user-hostile languages. I also tried to use Automator for this, and that went nowhere.
A more advanced script might check whether iTunes is running before blithely tossing commands at it. It might also create playlists that aren't there or take some kind of safety precautions. I doubt that I'll expand my AppleScript knowledge for the sake of those "advanced" features, but I'd be happy to hear from someone else who's done it.