How can we display duplicate files and missing files that we searched in folder, in command window?

1 view (last 30 days)
Riya
Riya on 24 Mar 2021
Commented: Riya on 25 Mar 2021
I need to make a function which would take three arguements. 1. source folder address (where all files are present) 2. destination folder address(where we need to copy files by matching it from excel sheet) 3.folder name (having some specific name)..then i need to read the excel file and search for files that are given in an excel sheet in a parent folder and then copy the files matching the files names in excel sheet to another folder((destination). While doing this need to display the duplicate and missing files of the parent folder in command window as well. How can I do that?
This is the code which i tried. It is copying the files properly and displaying them. But i need to display the duplicate and missing files of the parent folder in the command window . the source folder has 6 subfolders which has some specific starting name which makes them the folders of some same category. We are searching these files in all those subfolders here. Please help , how can this be done.
[file,path] = uigetfile('*.xlsx');
myexcel=readtable(file);
mydir='source folder address';
myartfiles=dir(fullfile(mydir,'**', '*.art'));
mycopydir='Destination Folder address';
samefiles=ismember({myartfiles.name}, myexcel.Tests);
filestocopy=myartfiles(samefiles);
r={filestocopy.name};
a=unique(r);
for k=1:length(a)
origpath=fullfile(filestocopy(k).folder,filestocopy(k).name);
destpath=fullfile(mycopydir,filestocopy(k).name);
copyfile(origpath,destpath);
end
h=msgbox(sprintf('%d number of files copied',k));

Answers (0)

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!