Please Note: This article is undergoing substantial revision and is not currently in a usable state. Please come back sometime around the end of November 2020!
I’ve written a number of scripts for ‘audio management’ which are freely available from this site. It doesn’t happen often these days, but occasionally I still use an old laptop or PC with Windows 10 on it. When I do, I’d prefer to use my own open-source scripts with which I’m familiar than closed-source (even if zero cost) proprietary software.
How, then, can Windows 10 be turned into a platform that permits the running of Linux scripts? In this article, I’ll explain how to install Cygwin and get it capable of running any of my scripts.
2.0 The Windows Subsystem for Linux
In earlier versions of this guide, I used Cygwin to create a virtual Linux system on top of a Windows PC. It was relatively small and efficient -but software versions change and the software landscape alters over time, so those instructions are no longer valid.
Instead, Microsoft has kindly included a way to run Linux in parallel with Windows called the ‘Windows Subsystem for Linux’ or WSL for short.
There are two versions of it: this guide only works with WSL version 2 (WSL2 for short). WSL2, in turn, requires you to be running a fairly recent version of Windows 10 (anything newer than an 1804 release should be fine) and that your PC has virtualisation extensions enabled. Most modern PCs today can certainly do virtualisation -but sometimes the option is turned off in the PC’s BIOS. Explaining how to enable that option is outside the scope of this article -because it depends whether you’re really using a BIOS, a UEFI firmware, the make of the PC and quite a few different options. I can, however, point you to this article which shows you two possible ways to enable virtualization capabilities on your PC (only one will probably actually be applicable in any given case, but you’ll maybe need to experiment to find out which option works for you).
2.1 Installing WSL2
Assuming your hardware is virtualization-enabled, here’s how you go about adding the WSL2 capabilities to your Windows PC.
First, run the PowerShell tool as an Administrator (so click Start, type ‘power’ and then right-click the ‘Powershell’ program and select ‘run as administrator’) and type or paste in the following command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Once that completes, do the same thing with this command:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Once the feature has installed, reboot your machine (the next command will error if you don’t!). Once the machine is back up and running, paste in this command:
wsl --set-default-version 2
Now at this point, you may see a message returned to the effect, ‘WSL 2 requires an update to its kernel component’. If you see such a message, visit https://aka.ms/wsl2kernel in a browser and click the link to ‘download the latest WSL2 Linux kernel update’. Save it somewhere to disk and run it once it’s been downloaded completely. With all of that done, you can finally close the Powershell program.
You now need to launch the Windows Software Store application and search for ‘Ubuntu 20’. Click ‘Get’ to make you ‘own’ the software, and then select to install it. Once it’s installed, you can either launch it from the Software Store by clicking the large ‘Launch’ button there -or, more sensibly, I think, click your Start menu and find the new ‘Ubuntu 20.04 LTS’ menu option. Click that and -on the first launch- you’ll see a command line window in which the program will say it is ‘Installing, this may take a few minutes…’.
Part of that installation procedure will be to prompt you to supply a new Unix username. It doesn’t have to be anything like, or have any resemblance to, your Windows username/password combo, but for the sake of sanity (and not having to remember multiple passwords!), it might make sense to keep them the same. The thing is, however, that you’re creating a new account purely for the Linux environment running inside Windows, so technically and accurately, they are two separate accounts.
Once you supply a username and a password (twice, for confirmation you can type properly!), you are left sitting at a command prompt, containing your new Unix username and the name of the Windows PC this is all happening on: you now have a functioning Linux system running inside Windows, which is a technical miracle if you ask me!
I would kick off your Linux-on-Windows experience by making sure your Ubuntu distro is completely up to date:
sudo apt update sudo apt upgrade
You should then add some key extra software, without which most good audio-related programs can’t work on any Ubuntu setup, even an ‘ordinary’ one on dedicated hardware:
sudo apt install ubuntu-restricted-extras
And to make the environment as normally-Ubuntu-ish as possible, create a couple of extra folders in your home directory, like so:
cd mkdir Downloads mkdir Music
You’re now ready to get the AbsolutelyBaching scripts working! But before you do, it might pay for you to work out how you ‘see’ Windows from your Linux environment and vice versa. For you will probably be wanting to tag files that a Windows ripper program has created, or convert music files that originally got created in a Windows folder.
2.2 Managing the Windows/Linux Divide
4.0 Getting the AbsolutelyBaching Scripts Working
For the most part, all the AbsolutelyBaching scripts work exactly as they would work on a “proper” Ubuntu distro. When you run them for the first time, they’ll work out what software is missing that is needed and prompt you with a suitable ‘sudo apt install….’ message about how you fix those missing dependencies up. Once you have done so, they work entirely normally.
The biggest difficulty, perhaps, is in actually getting the scripts into the WSL subsystem in the first place! You can’t run a browser and download the scripts via this website: if you try that, you’ll be running a Windows browser and only downloading to the Windows file system! Although WSL can then “see” those downloads, it’s certainly not a convenient way to do it. Therefore, I would suggest you simply cd to the Downloads directory you created back at Section 2.1, and then download the scripts using the wget utility, as follows:
- Classical CD Tagger: wget https://absolutelybaching.com/the-classical-cd-tagger-ccdt/
- AbsolutelyBaching Universal Audio Converter: https://absolutelybaching.com/the-absolutely-baching-universal-audio-converter/
- AbsolutelyBaching FLAC Checker: https://absolutelybaching.com/the-absolutelybaching-flac-checker/
For each download, copy it to the /usr/bin directory, chmod+x it, and then create an extension-less symbolic link to it. In general, you’d do that with these three commands:
sudo mv $HOME/Downloads/scriptname.sh /usr/bin sudo chmod +x /usr/bin/scriptname.sh sudo ln -s /usr/bin/scriptname.sh /usr/bin/scriptname
Replace ‘scriptname’ in that lot with the actual name of the script you’ve downloaded on each occasion.
You will notice that the Classical CD Ripper is not listed above. There’s a good reason for that: the way Microsoft makes WSL2 work means that the Linux environment has no meaningful access to a Windows PC’s physical optical drive(s). This is extremely unfortunate, but it is what it is (for now at least). In the meantime, I would suggest you rip your CDs to disk using the Exact Audio Copy program. Once the rips are completed with that, just copy them over into a WSL folder and use CCDT and AUAC to tag them up properly and process them into the audio formats you prefer.
WSL 2 makes running Linux scripts in a mostly-Windows environment really quite simple: but there are definitely drawbacks! That GUI Linux programs cannot easily be run from the Linux command line is a problem (I like to check what CCDT has done, for example, by reviewing its work in Easytag… but in WSL2, currently, a GUI program like Easytag can’t be easily run at all). The fact that the WSL2 environment has no access to the physical optical drives present on a system is also a showstopper for the Classical CD Ripper. Fortunately, there are adequate native Windows program equivalents (even if they do have the unfortunate tendency to offer to fetch metadata from the Internet, which is always a waste of time for Classical music recordings!)