Cribbed Windows script from https://github.com/nlowe/mousiki/commit/51bd789ec65fe87556ef3181cb388c26c3b3eb00