I am trying to read and store the file names from a directory to a list.
The folder structure is:
dataset
├── Type_a
│ ├── a1_L.wav
│ ├── a1_R.wav
│ ├── a2_L.wav
│ └── a2_R.wav
└── Type_b
├── a1_L.wav
├── a1_R.wav
├── a2_L.wav
└── a2_R.wav
The expected list output should be:
[[a1_L.wav,a1_R.wav],[a2_L.wav,a2_R.wav],[a1_L.wav,a2_R.wav],[a2_L.wav,a2_R.wav]]
Using the following code i am getting the file names but how it can be grouped into a list
import os
for i, ret in enumerate(os.walk('./dataset/')):
for i, filename in enumerate(ret[2]):
print("filename is",filename)
a1_L.wavalongsidea2_R.wav, which would break this rule. So what is the goal here?