您的位置:首页 > 编程语言 > MATLAB

MATLAB修改一文件夹下所有txt文件名

2018-02-28 09:33 417 查看
%% 修改txt文件名
clear
clc
close all

% 数据所在路径
datapath = 'E:\database\';
% 查看的数据列表
filelistName = 'filelist.txt';
filelist = strcat(datapath,filelistName);
fidfile = fopen(filelist,'r');
if fidfile < 0
error('数据文件名打开错误!');
end
% 结果所在路径
respath1 = 'E:\AllRes\';

tline = fgetl(fidfile);
fileno = 0;
val = 0;
while ischar(tline)
%%
rname = strtrim(tline);
if (1 == strncmp(rname,'#',1))
tline = fgetl(fidfile);
continue;
end
fileno = fileno + 1;
% txt文件名字符串的组合函数 strcat
oldname = strcat(respath1,'RefPlethPV_',rname,'.txt');
newname = strcat(respath1,'RefREDPV_',rname,'.txt');
% txt文件名修改函数 movefile
movefile(oldname,newname);

%% 读入下一条数据
tline = fgetl(fidfile);
end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐