I use this code to see existed files in a specific folder from FTP :
ftp_client = ftp('IP','Username','Password');
aa = dir(ftp_client,'First_folder/Second_folder');
I can see file names with these codes :
aa(1,1).name
aa(2,1).name
aa(3,1).name
How can I see all files names in a cell aray in this specific folder? Is there any command for it?
How can I count number of existed files in this folder?
How can I count number of existed files in this folder with a specific format?
Thanks.
A simple way is to collect the values into the cell array by using curly brackets: filenames = {aa.name};
The simplest method would be length(aa);
or length(filenames);
A couple ways. You can either refine your dir
call, aa = dir(ftp_client,'First_folder/Second_folder/*.jpeg')
for example, or use your own filter (regexp
is one option) on your filenames to return the indices of what you want.
As a general aside, if you're utilizing this program on different operating systems, I would recommend utilizing fullfile
(or filesep
at the very least) to build your full pathnames to ensure the right separator is used. Though I didn't do it in my example above...