Copying files based on file name in Matlab -
i want copy files 1 folder another, if filename begins letter 'w'. below script i've come far, it's not working. there 2 loops in script, because there files in 3 folders (i.e. subjects) , each of these folders has 4 subfolders, want scan through 'w*'-files. files should copied "folderx" "folderxnew".
for n_subj = 1:3 cwd_all = { '/data/subject1/'; '/data/subject2'; 'data/subject3'; }; cwd = cwd_all{n_subj}; dirs{1}='folder1'; dirs{2}='folder2'; dirs{3}='folder3'; dirs{4}='folder4'; dirt{1}='folder1new'; dirt{2}='folder2new'; dirt{3}='folder3new'; dirt{4}='folder4new'; nses=1:4 dir = dirs{nses}; files = dir('w*'); copyfile(files, dirt{nses},'f'); end end
can try loop:
for nses=1:4 files = dir([dirs{nses} '\w*']); =1:length(files) copyfile(files(i).name, dirt{nses},'f'); end end
Comments
Post a Comment