Collect recursively in a path with wildcard


#1

Hello :slight_smile:

I have samples in various hierarchical folders.
~ /Sound/animals/dog
~ /Sound/animals/cat
~ /Sound/animals/Cow
~ /Sound/animals/anotherAnimal

I would like to collect the cries of all animals, knowing that all the sounds of cry have “cry” in their file name, but can be stored in subdirectories (dog, cat, cow) Is this possible in a form of that type:

~ cry = Dictionnary.new;
~ cry.add (\ cry ->
  "~ /Sound/animals/*cry*".PathMatch.collect ({
    arg sf;
    Buffer.read (s, sf);
  });
);

#2

I found a solution to my problem using a unixCmd: unixCmdGetStdOut:

~fileBouchonH = "find ~/son/sons/cuisine/ -name bouchon_H* -type f".unixCmdGetStdOut; // Grab
~fileBouchonH = ~fileBouchonH.split($\n); //make a list - \n = new line /r = return
~fileBouchonH.pop; //remove last element of the list (why an empty entry in the end?)
~fileBouchonH; //result

~bufBouchonH = Array.new;
( //add a buffer to the array ~bufBouchonH, for each entrie in the list ~fileBouchonH
~fileBouchonH.do({
	|path|
	~bufBouchonH = ~bufBouchonH.add(Buffer.read(s, path));
});
)
~bufBouchonH;
~bufBouchonH.at(0).play;
~bufBouchonH.at(1).play;
~bufBouchonH.at(2).play;

Would there be a simpler way to proceed?
Any way, I’m glad I took a small step further :slight_smile: