matlab - Copy files with changing filename -


i'm trying copy several files changing filenames. seems easy can't seem work out how without listing out filenames in entirety. first few letters of filenames correspond subject names i'm looping through 1 one. in each folder, there 2 files, 1 subj1_load1_vs_load2.img, 1 subj1_load1_vs_load2.hdr. want both of them copied. below have:

subj={'subj1','subj2','subj3','subj4','subj5'}  i=1:length(subj)     source=fullfile(filedir,subj{i},sprintf('^%s_.*\.*',subj{i})); % doesn't seem work     destination=fullfile(destdir,subj{i});     copyfile(source,destination); end 

i've tried:

source=dir([filedir subj{i} strcat(subj{i},'*')]); 

this appears needlessly complicate since need deal .name. perhaps don't know how use well.

anyway, problem source i'm trying find files want copy.

i'd appreciate suggestions.

below daniel's answer (which solved issue me)

source=fullfile(filedir,subj{i},strcat(subj{i},'*')) 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -