MATLAB: How to filter files in matlab

copyfilefilereadfopenforismemeber

i have 1000 .txt files with different file name in a folder(MAIN) and i need to filter some files which the names are given in filestocopy.txt. i need to copy those mentioned files and stored in a separate folder..any help..for example..see below..
Inside MAIN folder
SAMPLE_20120807_1816.TXT
SAMPLE_20120807_1916.TXT
SAMPLE_20121207_1311.TXT
SAMPLE_20121307_1816.TXT
SAMPLE_20121322_1902.TXT
SAMPLE_20121412_1351.TXT
Inside filestocopy.txt
SAMPLE_20120807_1816
SAMPLE_20121207_1311
SAMPLE_20121412_1351

Best Answer

files={'SAMPLE_20120807_1816.TXT'
'SAMPLE_20120807_1916.TXT'
'SAMPLE_20121207_1311.TXT'
'SAMPLE_20121307_1816.TXT'
'SAMPLE_20121322_1902.TXT'
'SAMPLE_20121412_1351.TXT'}
files1=strrep(files,'.TXT','')
c=importdata('filename1.txt')
idx=ismember(files1,strtrim(c))
out=files(idx)
destintion='E:/'
for k=1:numel(out)
copyfile(out{k},destination)
end