Number of files in dictionary subfolder

I play samples/buffers out of dictionary. For choosing randomly all samples in a folder I need to know the number of files in the folder. How can i get the number of files?

n=number of files in folder “metalsounds”

then I do the lottery

\buf, b[\metalsounds][(0…n).choose],

Any idea how to do this?

see: PathName | SuperCollider 3.12.2 Help

(
var myPath;
myPath = PathName.new("./");
// myPath.files.postln;
"No files:   ".post;
myPath.files.size.postln;
)

Best,
Paul

1 Like