How can I create a string with name of a searched file?
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!