So, the basic idea is that I pirate music a lot and, as it sometimes is the case, am quite often lost when it comes to choosing something to actually listen to. (hey, boys and girls, that’s why you don’t pirate!)
Anyway, there’s this folder on my pc, called ~/Downloads/Music, right, and inside are a few hundred subfolders, each holding a different music album which I’ve downloaded (possibly a long while ago) but haven’t got time and/or resolve to listen to yet.
I used to count the number of albums with handy ls | wc -l line, then go to http://random.org to roll the appropriately-sided die a number of times.
Then it got tedious.
So I decided to make a simple python one-liner to do that for me. I mean, how hard could it be?
Turns out, not hard at all.
#! /usr/bin/python3 import os, random print('\n'.join(random.sample([d for d in os.listdir('.') if not os.path.isfile(d)], 10)))
Well, technically it’s a three-liner, but who cares. It gets the job done. Then I can use its output as an argument for mv so the randomly-chosen albums will get transferred to my mp3 player. Quite handy!
You realize you’ve been worshipping Eris your entire life.