MATLAB: How to create a string with name of a searched file

file searchMATLABstrings

Hi,
I have some files in a directory from which I have to search and get names of files containing string "bc". So, I have this code.
file_search_with_name = strcat('dir /B /S *bc*.txt');
[status, list] = system('dir /B /S *bc*.txt');
result = textscan(list,'%s','delimiter','\n' );
files = result{1};
In files I get strings which contain the filenames with entire path, like this.
files{1,1}
ans =
C:\Users\sj028179\Documents\Work\a\abcd.txt
How can I get rid of the directory path and just keep the filename in a string, like "abcd.txt"?
Thanks for the help.

Best Answer

f='your_folder'
d=dir(fullfile(f,'*bc*.txt'))
file={d.name}