How to Cut multiple files from multiple folders in a for loop? Then return them to their own folders containing those cuts.
Show older comments
I have this working section that I have run all my other m files for, but i can only do it for the 12 2sec cuts of the 1st wav file under the folder directory named basson.....the Basson folder has 10 total wav files in it though.
I would like to get this for loop to work through all of the main 4 folders of wav files and slit them all up into 2sec clips,? any suggestions would help greatly!
got to have all this cut up so i can compare each data set later in program......
only other way i can think of is hard coding it, but it was going upwards of 800+ lines! ha
that line gives me files like, 3Basson1.wav, 3Basson2.wav........to 12
hopefully i worded this correctly....
Thanks again
file_name=sprintf('%dBassoon%d.wav',3,i) %can this be changed to %d%dBassoon%d.wav, "something to increment them?",i)
%----------------------------------------------------
%what i have so far working for the very first of 10 wav files in that folder
filename='C:\Users\......\Bassoon\01_AchGottundHerr_bassoon.RESYN.wav'; %does this need to be a dir?
[y, fs] = audioread(filename);
k=ceil(length(y)/(2*fs));
mkdir Cut_Bassoon
% mkdir Cut_Clarinet
% mkdir Cut_Saxphone
% mkdir Cut_Violin
s=2*fs;
n = length(y);
for i = 1: (k-1)
file_name=sprintf('%dBassoon%d.wav',3,i);
file_name=strcat('C:\Users\.......\Cut_Bassoon\', file_name);
audiowrite(file_name,y((s*(i-1)+1): (s*i)),fs); % this does the actual segmenting into 2sec and sends to that dir
end
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!