Batch Changing Facebook Album Descriptions

Interlinking multipart albums.

I am doing an internship at Nara Institute of Science and Technology for 2 months. During my time here, I traveled a lot and took many photos, and uploaded them to Facebook.

The problem is that when there are so many photos in a single album, performance degrades (and kind of make it hard to manage the photos).

So I split my album into many parts (one for each week).

The problem: Make these albums interlinked by putting links in the description of each album linking to other albums.

Browser Automation

I decided to do browser automation, so I used watir-webdriver.

It lets you control any web browser supported by Selenium WebDriver, including Firefox and Chrome.

Logging in to Facebook

Since watir-webdriver allows running Firefox with a specific profile, I created a new Firefox profile for use with watir-webdriver.

I then logged in to Facebook inside that profile, so I don’t have to write code to automate the login process.

Updating Process

To make the script reusable, I make it read from a text file. Here is an overview of the process.

  1. The text file containing the description is read.
  2. Album URLs are scanned.
  3. For each album, its description is updated according to the text file.

The Script

This script, album_description.rb, reads the text file and updates the album descriptions accordingly.

The code is reproduced here:


Make sure you installed the watir-webdriver gem. Then create a text file and put the description inside.

Include the URL of each album inside the text file, since it is used by the script to scan for albums to update. For example:

This is the description of the album.
This album contains many parts.
Part 1:
Part 2:
Part 3:

Then run the script:

ruby album_description.rb path/to/file.txt

You should see something like this:

== Album Description Updater ==
There are 2 albums whose descriptions are to be updated!
- Updating: NAIST Internship [Week 0]
- Updating: NAIST Internship [Week 1]
All done!

Further Work

Now you can customize the script to your will, such as:

  • including the album number in the description (e.g. this is album 1 of 3).
  • setting a different description for each album.