Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
初级会员
注册日期: 2008-03-08
年龄: 40
帖子: 15
声望力: 18 ![]() |
![]()
Matlab清空指定文件夹
如何用matlab删除指定文件夹下的所有文本文件?? |
![]() |
![]() |
![]() |
#2 |
初级会员
注册日期: 2009-03-17
年龄: 39
帖子: 18
声望力: 17 ![]() |
![]()
把这个改改用吧。
%% 指定输入目录,搜索原始txt文件 INP = uigetdir('C:\','请指定删除txt文件的目录'); if INP ~= 0 % 判断是否指定了输入目录 structFiles = dir(INP); nMaxFileNum = length(structFiles); sTxtFiles = cell(1,nMaxFileNum); iTxtFind = 0; for idFile = 1:length(structFiles) % 判断文件 % 寻找Txt文件 if ~structFiles(idFile).isdir sName = structFiles(idFile).name; if length(sName)>4 % .Txt文件至少有四个字 sNameType = sName(end-3:end); sNameFirst= sName(1:end-4); if(strcmp(sNameType,'.Txt')||strcmp(sNameType,'.txt')) % this is a txt file iTxtFind = iTxtFind + 1; sTxtFiles{iTxtFind} = sNameFirst; end end end end % 判断文件结束 sTxtFiles = sTxtFiles(1:iTxtFind); sFindFile = strcat('共发现Txt文件个数: ',int2str(iTxtFind)); disp(sFindFile); end |
![]() |
![]() |
![]() |
主题工具 | |
显示模式 | |
|
|
![]() |
||||
主题 | 主题作者 | 版面 | 回复 | 最后发表 |
[MATLAB基础] 怎么把两个变量整成一个 | fany_涅槃 | MATLAB论坛 | 2 | 2009-05-07 21:05 |
北京航空航天大学matlab立体解决方案 - 投影时代 | labfans | MATLAB新闻聚合 | 0 | 2009-04-03 14:00 |
如何实现gui窗口嵌套 | beulah | MATLAB论坛 | 1 | 2008-12-28 17:57 |
[求助]彩色图的显示 | nancy2008521 | MATLAB论坛 | 2 | 2008-05-15 13:05 |
[求助]如何编写接口函数 | summermoon | MATLAB论坛 | 0 | 2008-05-08 11:36 |