Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
 
 
主题工具 显示模式
旧 2009-03-17, 12:43   #2
applef
初级会员
 
注册日期: 2009-03-17
年龄: 39
帖子: 18
声望力: 17
applef 正向着好的方向发展
默认 回复: [求助]Matlab清空指定文件夹

把这个改改用吧。

%% 指定输入目录,搜索原始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
applef 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码


相似的主题
主题 主题作者 版面 回复 最后发表
[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


所有时间均为北京时间。现在的时间是 19:28


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.