How to compare contents of folders, check for missing files?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Louise Wilson
el 2 de Oct. de 2019
Respondida: Walter Roberson
el 2 de Oct. de 2019
I have a folder of files, which contains .sud files and .wav files. The .wav files are decompressed .sud files and should be equal in number, however, I can see from checking the length of each of these that there is one less .wav file. It looks like one hasn't been processed and I'd like to know which one it is. How can I do this? I've put the filenames in two columns of an array and the empty cell looks like [ ].
Here is my code so far:
directory={'Y:\SoundTrap\Tawharanui\Tawharanui_5278'};
for j=1:length(directory)
folder=char(directory(j));
d=dir(fullfile(folder, '*.wav')); %list all .wav files in path folder
wavfiles=length(d);
%wavfiles=6337
e=dir(fullfile(folder, '*.sud')); %list all .sud files
sudfiles=length(e);
%sudfiles=6338
row=1;
%wavs in first column
for i=1:wavfiles %get filename only (remove prefix and suffix)
disp(d(i).name);
SN=strsplit(d(i).name,'.');
wavfilename=SN(2);
outputfiles(row,1)=wavfilename;
row=row+1;
end
row=1
%suds in second column
for z=1:sudfiles
disp(e(z).name);
SN=strsplit(e(z).name,'.');
sudfilename=SN(2);
outputfiles(row,2)=sudfilename;
row=row+1;
end
end
wavfiles=outputfiles(:,1);
sudfiles=outputfiles(:,2);
0 comentarios
Respuesta aceptada
Walter Roberson
el 2 de Oct. de 2019
[~, wav_base_names] = fileparts({d.name});
[~, sud_base_names] = fileparts({e.name});
unmatched_files = setdiff(sud_base_names, wav_base_names);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Coder 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!