0

play ~/Music/audio0.flac repeat -

A command for playing a single specific audio file on repeat.

play ~/Music/${random_audio_file} repeat -

A pseudo command for playing a single random audio file from the given directory (~/Music/), also on repeat.


How to do the latter as a real working command?

01AutoMonkey
  • 314
  • 3
  • 10

2 Answers2

1

You can leverage the shuf command for that. Try:

play "$(find ~/Music -name '*.flac' | shuf -n 1)" repeat -

The double quotes are necessary in case your filenames may contain spaces.

Tilman Schmidt
  • 1,223
  • 1
  • 11
  • 16
0

This command will get a random .flac file and play it using omxplayer. Modify the command to suite your player.

find . -type f -name '*.flac' | shuf -n 1 | xargs -d "\n" omxplayer
harrymc
  • 455,459
  • 31
  • 526
  • 924