filedir='E:/source/Wavfile/*.wav'; % 设置路径
outfiledir='E:/output/Wavfile/';
infiledir='E:/source/Wavfile/';
files = dir(filedir);
for i = 1 : length(files)
infile = [infiledir,files(i).name];
[x,fs] = audioread(infile);
x_L = x(:,1);
x_R = x(:,2);
y = x_L + x_R;
outfile_L = [outfiledir,files(i).name(1:end-4),'_L.wav'];
outfile_R = [outfiledir,files(i).name(1:end-4),'_R.wav'];
outfile_Y = [outfiledir,files(i).name(1:end-4),'_Y.wav'];
audiowrite(outfile_L, x_L , fs);
audiowrite(outfile_R, x_R , fs);
audiowrite(outfile_Y, y , fs);
end