Sockpuppet Blog.

Bulk-editing Bandcamp per-track pricing

Bandcamp recently rolled out bulk editing for albums, but unfortunately it only lets you bulk-edit album prices, rather than the prices of individual tracks within an album. Fortunately, it isn’t too difficult to do this with a little Javascript.

For each album that you want to change the prices on:

  1. Open up your album’s editor

  2. Open up your browser’s Javascript console (usually using ctrl-alt-I on a PC, or cmd-alt-I on a Mac)

  3. Paste in this bit of code (assuming you want to set the price to 1.50 per track in your local currency; change the '1.50' to whatever value you want it to be otherwise) and press Enter:

    document.querySelectorAll('input.price[name^="track.price"]')
        .forEach(e=>{e.value='1.50';e.dispatchEvent(new Event('change'))})
    
  4. Verify that the prices are the way you want them and then click “update album”

Note that copy-pasting random Javascript from the web is generally unsafe to do, so I’ll explain exactly what this code does:

  1. document.querySelectorAll asks the browser to give a list of items on a webpage; in this case, the query input.price[name^="track.price"] asks for all of the text inputs which have a class of price and a name starting with track.price, which is how Bandcamp marks a text input as being a track price
  2. forEach runs a function on each of the text inputs; in this case, for each one, it
    1. sets the value attribute (which is the text in the box) to 1.50
    2. notifies the browser that the value has changed (which is necessary because Bandcamp is using custom validation and data binding logic)

Anyway. This is still not great, process-wise, but it’s a lot easier than having to edit every single track manually.