How to Cut multiple files from multiple folders in a for loop? Then return them to their own folders containing those cuts.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
morgan mcvay
el 4 de Dic. de 2020
Comentada: Paul Hoffrichter
el 7 de Dic. de 2020
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
0 comentarios
Respuesta aceptada
Paul Hoffrichter
el 4 de Dic. de 2020
You can recursively find all files with a .wav extension using code from here:
But without the metadata in some of the .wav files that you create, it appears that you have to handle separately the first .wav file that has the metadata from the rest that do not.
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!