MATLAB: Read all audio files in one directory

audiofilereadfilterFilter Design Toolboxit's in the faqmp3

Hi, I want to remove a frequency from all my mp3 songs, my idea is to use the audioread and audioinfo functions to copy a song in my workspace, see if i can use the filter I created, with a sample rate of 44.1kHz and cut out the frequency (1kHz +/- 300Hz). With audiowrite I can create a .wav file without that frequency. But its a lot of work to do that for every song, is it possible to read the first song in one directory, filter it and generate a wav file in another directory and continue with the second song in the directory and so on? audioread expects the whole filename, I have no idea how to find out how many and which songs are in the directory, can anyone help me?

Best Answer

folder='C:\Users\malek\Documents\MATLAB'
audio_files=dir(fullfile(folder,'*.m'))
for k=1:numel(audio_files)
filename=audio_files(k).name
%Do what you want with filename
% create a new file name 'new_file' for example
folder_destination='C:\Users\malek\Documents' % for example
file_dest=fullfile(folder_destination,'new_file'
% .....
end