Compare directories with subdirectories and output how many files are the same from two different directories with same subdirectories.

2 visualizaciones (últimos 30 días)
I need to count how many files are are different in two directories with subdirectories. So I want a program to run though the main directory, look through all the subdirectories and see which files are different from another main [student] directory (has the same files but they are randomized). So I need matlab to output how many files are correct when you compare the main directory versus the student directory. I will need to compare 20 students directories with the main directory. Which student has the closest match to the main directory wins a challenge. Here is what I have so far.
mainPath = '/Users/Documents/Lesson_Lisa_Italy_2015/';
studentsFolder = '/Users/Documents/Lesson_Lisa_Italy_2015 copy/';
choosenFolder = uigetdir(studentsFolder);
if choosenFolder == 0
return;
end
main = dir( mainPath );
user = dir( choosenFolder );
filenames = getAllFiles('/Users/Documents/Lesson_Lisa_Italy_2015/');
filenames = dir( filenames);
filenames_student = getAllFiles( choosenFolder );
for n = 2:numel(filenames)
names = char(filenames(n));
[pathstr,name,ext] = fileparts(names);
main( [main.isdir] ) = [];
user( [user.isdir] ) = [];
files_not_in_choosenFolder = setdiff( {main.name}, {user.name} );
files_not_in_mainPath = setdiff( {user.name}, {main.name} );
if isempty(files_not_in_choosenFolder) && isempty(files_not_in_mainPath)
disp( 'same files in the two folders' )
end
end
Thank you in advance!

Respuestas (0)

Categorías

Más información sobre File Operations 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!

Translated by