MATLAB 读子文件夹下文件

把符合的文件路径保存到fp中,FileType为指定文件的类型,MainPath为文件夹的路径

function Path=ReadFile(fp,MainPath,FileType)
%%%%%%%%%%%%%%
%MainPath为主路径,FileType为需要读取的文件类型
PathFileFormation=dir(MainPath);
PathNumber=numel(PathFileFormation);
for LoopPathNumber=1:PathNumber

if( isequal( PathFileFormation( LoopPathNumber ).name, ‘.‘ ) || ...
isequal( PathFileFormation( LoopPathNumber ).name, ‘..‘ )) % 如果不是目录跳过
continue;
elseif PathFileFormation( LoopPathNumber ).isdir
Path=fullfile(MainPath,PathFileFormation(LoopPathNumber).name);
Path=ReadFile(fp,Path,FileType);
else

Path=fullfile(MainPath,[‘*‘,FileType]);
images=dir(Path);
for i=1:numel(images)
fprintf(fp,‘%s\n‘,fullfile(MainPath,images(i).name));
end
break;
end

end

时间: 2024-08-25 21:08:58

MATLAB 读子文件夹下文件的相关文章

Java与Python统计文件夹及子文件夹下文件个数

package dang; import java.io.File; /** * @ClassName: FileCount * @Description: TODO() * @author: dangjinhu * @date: 2018年11月1日 下午2:24:58 */ public class FileCount { public static void main(String[] args) { int[] array = new int[]{0,0}; print(new File

MATLAB遍历子文件夹及其下文件

MATLAB遍历子文件夹及其下文件 以前从未遇到过用MATLAB批处理文件的情况,此次项目需要批量将二进制数据文件导入matlab进行svm分类,现将matlab遍历子文件夹及其文件的方法记录下来. 文件目录结构 /maindir |-- subdir1 |-- datafile1.dat |-- datafile2.dat |-- subdir2 |-- datafiel3.dat |-- datafiel4.dat |-- subdir3 |-- datafile5.dat |-- data

nodejs 文件系统(fs) 删除文件夹 及 子文件夹下的所有内容

http://blog.163.com/hule_sky/blog/static/2091622452015112821829773/ node 文件系统fs 为我们提供了一些方法 进行文件和文件夹的读写删除等操作 下边将介绍删除文件夹及子文件夹下的所有内容的相关命令(均含有同步和异步方法) 1. fs.stat && fs.statSync 提供了访问文件的属性信息 2. fs.readdir && fs.readdirSync 提供读取文件目录信息 3. fs.unli

Java 遍历指定文件夹及子文件夹下的文件

/** * 遍历指定文件夹及子文件夹下的文件 * * @author testcs_dn * @date 2014年12月12日下午2:33:49 * @param file 要遍历的指定文件夹 * @param collector 符合条件的结果加入到此List<File>中 * @param pathInclude 路径中包括指定的字符串 * @param fileNameInclude 文件名称(不包括扩展名)中包括指定的字符串 * @param extnEquals 文件扩展名为指定字

遍历文件夹及其子文件夹下的.pdf文件,并解压文件夹下所有的压缩包

List<PDFPATH> pdfpath = new List<PDFPATH>(); List<string> ziplist = new List<string>(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrows

matlab 把一个文件夹下的所有图片(可以包含在子文件夹下)考到指定文件夹下

clc;clear all; maindir = 'C:\Users\wang\Desktop\iLIDS-VID\i-LIDS-VID\images\cam2';subdir = dir( maindir ); % 先确定子文件夹 for i = 1 : length( subdir ) if( isequal( subdir( i ).name, '.' ) || ... isequal( subdir( i ).name, '..' ) || ... ~subdir( i ).isdir

BAT 遍历文件夹和子文件夹下所有文件

echo off & color 0A ::指定起始文件夹 set DIR="%cd%" echo DIR=%DIR% :: 参数 /R 表示需要遍历子文件夹,去掉表示不遍历子文件夹 :: %%f 是一个变量,类似于迭代器,但是这个变量只能由一个字母组成,前面带上%% :: 括号中是通配符,可以指定后缀名,*.*表示所有文件 for /R %DIR% %%f in (*.txt) do ( echo %%f ) pause

FATFS-f_deldir-删除文件夹(删除子文件夹及文件连同其本身)

转载请注明出处:http://blog.csdn.net/u011833609/article/details/47803551 //==================================================================================================== //函 数 名 : f_deldir //函数功能 : 移除一个文件夹,包括其本身和其子文件夹,子文件 //输 入 : const TCHAR *path---指向

Python扫描指定文件夹下(包含子文件夹)的文件

扫描指定文件夹下的文件.或者匹配指定后缀和前缀的函数. 假设要扫描指定文件夹下的文件,包含子文件夹,调用scan_files("/export/home/test/") 假设要扫描指定文件夹下的特定后缀的文件(比方jar包),包含子文件夹,调用scan_files("/export/home/test/", postfix=".jar") 假设要扫描指定文件夹下的特定前缀的文件(比方test_xxx.py).包含子文件夹,调用scan_files