How can I create a string with name of a searched file?
1 view (last 30 days)
Show older comments
Mohammed Jahan
on 7 Aug 2015
Commented: Mohammed Jahan
on 10 Aug 2015
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.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on File Operations 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!