This code will allow you to import and export all of the audio files in your current folder:
    fileNames = dir('*.wav');     
    fileNames = {fileNames.name}; 
    
    for i = 1:numel(fileNames)
        [y, Fs] = audioread(fileNames{i});
        
        audiowrite(['out_' fileNames{i}],y,Fs);
    end
To get the portion of the file use the:
If you don't know the duration of each of the files these are the steps you need to take:
- Get the total duration of a file
durationInSeconds = size(y,1)/Fs
- Specify the duration of your sound bite i.e 10s
- Having all this information, you know that your sound bite can start at any point between 0s and durationInSeconds - soundDuration
- Now you need to generate the random soundbite start using:
randomStart = randi([0, durationInSeconds - soundDuration]);
- Once you've got the start, add the sound bite duration to it, convert to new y and write as a new sample