Shuffle Using SoX

musicmusic playersox

Is there anyway to shuffle songs using play on a folder using SoX?

play ~/Music/*/**

Best Answer

You can use sort -R to reorder the file list into "random" order. The command could be the following:

find ~/Music -type f | sort -R | xargs -I + play +

Here find ~/Music -type f results in a list of of all files in the Music subtree, recursively. The resulting pathname list is then "sorted" into a random order by sort -R, and passed as arguments to successive play invocations with some few/many pathnames at a time. Note the use of + as "replace string", to invoke individual play for each music file.

(Edit: as per Warren's comment below, I've now removed the useless but harmless single quotes for the second +.)

Related Question