matlab遍历文件夹下的所有文件
2015-05-26 10:46
736 查看
输入为目录,输出为cell数组。使用第i个文件时,文件名为files{i}。
function [ files ] = scanDir( root_dir ) files={}; if root_dir(end)~='/' root_dir=[root_dir,'/']; end fileList=dir(root_dir); %扩展名 n=length(fileList); cntpic=0; for i=1:n if strcmp(fileList(i).name,'.')==1||strcmp(fileList(i).name,'..')==1 continue; else fileList(i).name if ~fileList(i).isdir full_name=[root_dir,fileList(i).name]; % [pathstr,name,ext,versn]=fileparts(full_name); % if strcmp(ext,'.jpg') cntpic=cntpic+1; files(cntpic)={full_name}; % end else files=[files,scanDir([root_dir,fileList(i).name])]; end end end end
相关文章推荐
- MATLAB遍历主文件夹下所有子文件里的特定格式文件
- 遍历文件夹下的所有文件
- C++遍历文件夹下的所有文件
- JAVA遍历一个文件夹中的所有文件
- JS如何遍历一个文件夹下的所有文件与目录
- C#遍历指定文件夹中的所有文件
- matlab中怎样读取一个文件夹里面的指定类型的所有文件的名称?
- Java中遍历一个文件夹下所有文件及目录的操作
- Python:遍历输出某路径下的所有文件和文件夹
- 如何遍历所有文件夹,获取某一类型文件
- JAVA遍历一个文件夹中的所有文件
- 复制一个文件夹下的所有文件(复制文件、遍历目录)
- 遍历出一个文件夹下的所有文件,
- C#遍历指定文件夹中的所有文件
- PHP遍历文件夹下所有文件
- JAVA 遍历文件夹下的所有文件
- 遍历一个文件夹下面的所有文件MFC版本
- Android编程读取Assets所有文件(遍历每一个文件夹)并存入sdcard的方法
- 非递归遍历指定文件夹下的所有文件及其子文件夹
- java遍历一个文件夹中的所有文件