简体   繁体   English

MATLAB:打开和编辑嵌套在文件夹中的文件夹中的文件

[英]MATLAB: Opening and Editing Files nested in folders in folders

I'm working on a project where I need to pull files from this expansive directory with many subfolders nested in folders. 我正在一个项目中,我需要从这个扩展目录中提取文件,其中许多子文件夹嵌套在文件夹中。

I'm a complete novice when it comes to using matlab and directories, and I was wondering if anyone could help get me started! 对于使用matlab和目录,我是一个完全的新手,我想知道是否有人可以帮助我入门!

I've been using mainFolder = dir(fullfile(uigetfile)) to open the original main directory and then grabbing other folders using more fullfile and wildcards for things they contain. 我一直在使用mainFolder = dir(fullfile(uigetfile))打开原始主目录,然后使用包含更多内容的完整文件和通配符来获取其他文件夹。 I just don't know how many sub_folders MATLAB will open and let me edit 我只是不知道MATLAB将打开多少个sub_folders并让我编辑

I've written in english essentially what I need the code to accomplish - I'm not expecting someone to write this for me, just provide me with tips on how to get started! 我基本上已经用英语写了我需要完成代码的东西-我不希望有人为我写这个,只是给我一些入门的技巧!

%function getvariables

%open mainFolder

%open "dates" %name of subfolder in mainFolder

%open "experiment" %name of subfolder in dates

%open "analysis" %name of subfolder in experiment

 if .mat filename includes the string pre
     % pull variables from the .mat file
     % figure out if it contains a certain string of numbers ex. 1234
 if .mat filename includes the string post
     % pull other variables from the .mat file
     % figure out if it contains a certain string of numbers ex. 1234
 else
     % pull other stuff
     % figure out if it contains a certain string of numbers ex. 1234
 end

%load .mat file with the same numbers ex. 1234.mat from ANOTHER folder

%add the variables I grabbed from the pre/post/else .mat files to the loaded 1234.mat file

%save the newly updated 1234.mat file

%run this for a hundred or so different files...

Thanks, 谢谢,

ML ML

Check out subdir! 看看subdir! On the file exchange, its an awesome function that can return all folders and all files in expansive subfolders, and you can filter file names by extension and whatnot. 在文件交换上,它的功能很棒,可以返回所有文件夹和扩展子文件夹中的所有文件,并且您可以按扩展名和其他方式过滤文件名。

http://www.mathworks.com/matlabcentral/fileexchange/15859-subdir-a-recursive-file-search http://www.mathworks.com/matlabcentral/fileexchange/15859-subdir-a-recursive-file-search

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM