More Google App Scripts

Another useful script, check if the maximum number of responses has been received, and, if so, closing the form (also opening and closing on particular date/time). Here.

 

Tagged with: , ,
Posted in Scripts

Confirmation emails from Google Form

I use Google Forms for event registration, and the notification email from Google is nice, but I want to be able to send an email to people after they’ve registered, possibly including information which is not on the generally available form.

Here are the steps involved:

  1. From your Google Form, be sure that you have a field called “Email” where the submitter will input their email address.
  2. Save your Google Form responses in a separate spreadsheet, open that sheet and choose the Tools –> Script Editor.
  3. Include this Google Script into the script editor and save the script (floppy drive icon).
  4. Inside the Script Editor, choose Run — Initialize and authorize the script to send emails on your behalf.

When anyone submits the form, they’ll get an confirmation email in HTML. You will be included in the BCC.

Tagged with: ,
Posted in Scripts

Javascript: iTunes

Funny, I forgot one of the “classic” scripts which is very simple but quite useful.

This one refreshes your library with information found in the actual files associated with each library entry. So it has two effects: finds all “dead” tracks (tracks for which their is no corresponding media file) without you manually having to “Get Info” on a track and then sit holding ALT+N (on Windows) to go to the Next track while iTunes opens ever track in your library and updates any information in the file which is different from the library entry (for example, if you copy updated tracks from a second iTunes library and have updated the entries via your other iTunes library).
RefreshFromFile.js

Tagged with: ,
Posted in Scripts

Javascript iTunes: debugging

One other thing that is very important to me is debugging.

Now I am very much not impressed by the default Windows Javascript debugger, so I use a lot of logging of operations. This is rarely mentioned by others, so I bring it up here.
Having popups with WScript.echo() drives me crazy (I won’t click “OK” 1000 times while running a script to find tracks without artwork in my library) and having the default debugger pop up means that there is a problem with my Javascript.

So I do a lot of logging of operations, stuff like this:

var logFile = fso.CreateTextFile("CopyAlbumArtwork.log", true);

Then I can write progress information to this log file and review what works and what doesn’t; eventually taking manual actions to resolve problems (like a weird song with the album name in Japanese characters).

Tagged with: ,
Posted in Scripts

Javascript iTunes: scripts

Over the past months (nay, years) I have been cleaning up my music library. I have used different tools and services (including paying ones like Tune-Up).  But, I am lazy, my goal has always been to automate things as much as possible. So I was very happy to find various scripts which will, for example, search for “dead” tracks (tracks for which their is no corresponding media file) rather than having to “Get Info” on a track and then sit holding ALT+N (on Windows) to go to the Next track while iTunes opens ever track in my library to see how many “broken” links I have.

I have found a few different sources (some of which are just copies of each other or copies of examples from Apple) to “Manage iTunes on Windows using JavaScript with the iTunes SDK”. Obviously, there is also the iTunes COM Windows SDK which includes a few JS samples.
Here are a couple of links to other sources of Javascript for iTunes.
OttoDestruct
EverythingiTunes
Brian Ander

Here is also a good site with the COM interface of iTunes.

Now, for me, these are good resources, but what I am missing is some more powerful and tricky scripts. For example, I have recently subscribed to iTunes Match so that I can upgrade my older MP3 ripped music into higher bitrate audio (e.g. 256 kbps AAC).
The problem that I have with this is that the “Matched AAC audio file” that iTunes Match allows me to download has my iTunes account stamped into it. So what if I want to share this audio file with family or friends? What happens (hopefully far in the future) when I die and my iTunes account is no longer active and iTunes Match is turned off?
Well, basically, I’d like to have the audio files in a format which I own, not which Apple controls (e.g. “AAC audio file”, not “Matched AAC audio file”).

And now, here comes the reason for this posting. I have several playlists of hundreds and thousands of songs. Most of those playlists are built from converted (MP3) and purchased (“Purchased AAC audio file”) tracks, so I can’t upgrade from MP3 files or Purchased AAC to Matched AAC audio files and then and delete the MP3 or Purchased version.
So, I started working on somewhat more complex scripts which would help me smoothly upgrade my collection to clean AAC audio files without the traces of purchase or iTunes matching.

These scripts are not perfect and certainly need some upgrading, but as I find them useful you might as well.

  1. This first one does the main job of finding all tracks of kind “Matched AAC audio file” and running the iTunes ConvertFile2(). Please note that this assumes that you have the correct audio converter setup in iTunes; I know that it is possible to set the audio converter (and reset it to the original converter when done, but I couldn’t be bothered to implement that yet):
    ConvertMatched.js
  2. This one is a bit more specific to my situation. I followed guides about iTunesMatch upgrading of songs (MacWorld), but then found that some of my upgraded songs (cleaned up with the script from #1 above) did not have artwork. So I restored them from the Recycle Bin (to a different location than my actual iTunes library, so that my active library is on E: and the restored files are on C:). NB: this scripts makes some assumptions, so don’t just use it blindly:
    FindArtwork.js
  3. And that got me thinking, some of these albums already have artwork, just not on the upgraded (via iTunes Match) songs. So, another script was born:
    CopyAlbumArtwork.js
    This is similar to Brian Anders’ SelectedArtworkUnify.js, but I think it’s improved.
    Here I add a word of warning, this script should work fine except for albums of different artists with the same name like “Greatest Hits”.
  4. Here is the simple, classic “NoArtwork.js”, but be aware that a Smart Playlist in iTunes is more powerful as it can be defined to update “live” (each time a track gets artwork it is automatically removed from the playlist: no human intervention required).
    NoArtwork.js
    If you don’t know how to make a Smart Playlist to show all Music tracks without Artwork, then just ask, and I’ll post how that is done.

To use any of these scripts, just download them, save them to a file with a name ending *.js file, then run them like any other program (double click, select and press enter, type the name from a command prompt, etc). If you have the Windows Scripting Host installed on other Windows boxes (installed by default), then the wscript.exe program actually runs the scripts, much like cmd.exe runs batch files. The scripts connect to iTunes as a COM object and use it in that fashion.

Thanks for reading!

Tagged with: , , , ,
Posted in Scripts