how to check the path of each file and compare it with a string and if it matches copy them into new folder?
2 ビュー (過去 30 日間)
古いコメントを表示
hello, i need to make a function in which there will be 3 parameters...first two arguments will be source folder and destination folder address respectively.and third will be a folder name. in the source folder there are 6 subfolders in which 3 folders are having _201_ digit in their name and next three are having _678_ in their name.
The three folders having in their name _201_ contain some .art files and folders having _678_ also have same .art files. and also it will take an excel file from user.
now,the function will check for every file in all the subfolders of source folder and compare its name with that in excel file if the name matches.it will store the path of the file of source folder and check in its path if the name which is given in the third argument( i.e _201_ or_678_) matches with the path. if it matches, then copy that file into destination folder.otherwise show that file as duplicate file in command window. and also after the files are copied i have to show how many files are copied in the destination folder
This is the code which i wrote.please help me further to complete the function.
function myfunction(source,destination,foldername)
[~,~,file] = uigetfile('*.xlsx');
myexcel=xlsread(file); %read the excel file
addpath(genpath(source)); %add the source folder address to path
myfiles=dir(fullfile(source,'**', '*.art'));
end
0 件のコメント
回答 (1 件)
Image Analyst
2021 年 3 月 25 日
You don't need addpath() - just use fullfile(). To compare strings, use ismember(), contains(), and/or strfind().
2 件のコメント
Image Analyst
2021 年 3 月 26 日
First read this: MATLAB Academy - Free 2 hour training
Next read the documentation on those functions.
Then make a stab at actually using those functions.
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!