如何通过 MATLAB 更改文件扩展名?
How to change files extension via MATLAB?
我想更改几个文件的扩展名。
我的意思是在一个目录中我有很多类型为 file1.out
, file2.out
, ..., file600.out
.
的文件
我想将这些文件重命名为 *.txt
(我的意思是 file1.txt
、file2.txt
、...、file600.txt
) MATLAB?
我的意思是我想将一些文件的扩展名从 *.out 更改为 *.txt 文件。
here 中的这段代码可能会有帮助:
% Get all text files in the current folder
files = dir('*.out');
% Loop through each file
for id = 1:length(files)
% Get the file name
[~, f,ext] = fileparts(files(id).name);
% change the extension
rename = strcat(f,'.txt') ;
movefile(files(id).name, rename);
end
我想更改几个文件的扩展名。
我的意思是在一个目录中我有很多类型为 file1.out
, file2.out
, ..., file600.out
.
我想将这些文件重命名为 *.txt
(我的意思是 file1.txt
、file2.txt
、...、file600.txt
) MATLAB?
我的意思是我想将一些文件的扩展名从 *.out 更改为 *.txt 文件。
here 中的这段代码可能会有帮助:
% Get all text files in the current folder
files = dir('*.out');
% Loop through each file
for id = 1:length(files)
% Get the file name
[~, f,ext] = fileparts(files(id).name);
% change the extension
rename = strcat(f,'.txt') ;
movefile(files(id).name, rename);
end