matlab 修改文件夹下所有文件名大写为小写
2017-03-06 23:01 fdd566 阅读(2141) 评论(0) 编辑 收藏 举报1、
path = './DIR/';
Files = dir(fullfile(path,'*.m'));
LengthFiles = length(Files);
for count_i = 1 : LengthFiles;
flag = 0;
origin_name = Files(count_i).name;
for count_j = 1 : length(Files(count_i).name)
if ( Files(count_i).name(count_j) <= 'Z' ) && ( Files(count_i).name(count_j) >= 'A' )
Files(count_i).name(count_j) = Files(count_i).name(count_j) + ('a' - 'A');
flag = 1;
end
end
if flag == 1
realName = [path, origin_name];
tmpName = [path, 'azbxsjdskjfslkdjflksdjfsldkjf'];
changeName = [path, Files(count_i).name];
movefile(realName, tmpName);
movefile(tmpName, changeName);
end
end
2、movefile对文件名不区分大小写 所以这里直接运行会出错。