How to remove duplicates from your Google Music library using the gmusicapi and Cygwin on Windows

John M. Kuchta
Nov 23, 2015 · 3 min read

Update: If you’re using Windows 10 Anniversary Update and you have Bash installed, and/or want to use Python 3.5, I’ve updated the script for Python 3.5 and you can save yourself some work and skip Cygwin. Check this out.

I previously showed you my guide for removing duplicates from Google Music using the unofficial gmusicapi and OS X. OS X offers a full POSIX command line which makes it easy to work with Python (as a long-time Windows user, I wonder if this is actually OS X’s greatest single feature). Python does offer an installer/interpreter for Windows, but the Windows Command Prompt doesn’t play nicely with many Python scripts due to differences in Unicode handling, so we’re not going to use it. Instead, a few brilliant minds have blessed the Earth with Cygwin, which gives us POSIX functionality on Windows. If you’re running Windows and are ready to strip duplicates from your Google Music library, look no further.


To follow my guide, you’ll need:

  1. A PC running Windows (I have only tested on Windows 10). If you’re on a Mac, follow my tried and true OS X guide.
  2. A solid web connection. I recommend Google Fiber or FiOS. If you can’t already get it in your area, ensure you’re voting for candidates that promote competition in the broadband space.
  3. Some experience with a POSIX command line (and if you need it, I recommend completing this tutorial).
  4. A Google Music library.
  5. Cygwin and a few dependencies. We’ll install this in step 1.
  6. The unofficial gmusicapi. We’ll install this in step 2.
  7. If you are using two-factor authentication on your Google account, you will also need an application-specific password to use exclusively with the gmusicapi. If you’re not using two-factor authentication, you probably should be.

Step 1: Install Cygwin and the gmusicapi dependencies

We need to install Cygwin and several additional packages selectable during the installer. Grab the Cygwin installer and start the wizard. When prompted to choose packages, add these:

Devel > gcc-core, gcc-g++, openssl-devel
Python > python (Python language interpreter), python-setuptools
Web > wget
Libs > libffi-devel

and follow the on-screen instructions to finish the installation.

Step 2: Start the Cygwin terminal

Hit Start and type Cygwin and choose Cygwin Terminal. The terminal looks like the Windows Command Prompt except that it is actually useful.

Step 3: Install the gmusicapi

pip makes installing Python packages easy. In Cygwin,

easy_install-2.7 pip
pip install gmusicapi

If you get any errors, you’ve missed something. Review the prerequisites and especially ensure you’ve installed all dependencies using Cygwin.

Step 4: Download

Save it somewhere convenient. This is the script that’s going to do the heavy lifting identifying your duplicates, and offer to delete them. You may review the source code here.

Step 5: Run

Cygwin uses a different root directory than you may expect. To access your Windows drives, type

cd /cygdrive/

To list your drives. Then navigate to the folder where you saved Then run:


When you’re prompted for Username, use your Google email address. When you’re prompted for your password, provide your application-specific password. Once logged in, the script will show you a list of duplicates in your account — there may be hundreds. It will ask if you want to delete duplicates. Well, yeah, at this point, you probably do.


The API can only return so many results at a time, so if you have a large enough library, you’ll need to run the script multiple times. Run the script again (you’ll be prompted to log in each time) until the script reports “no duplicates found” — at which point you are done!

Keep on keeping on,


John M. Kuchta

Written by

Information infrastructure evangelist // WiFi engineer // Film nerd

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade