Moving Bulk MATLAB file to different folders

1 次查看(过去 30 天)
I m moving bulk matlab files to a different folder .For one file I did using Movefile command....Can someone suggest code for loading the file in one go instead of using Movefile command everytime ...Like Case161.mat to case 161 then case163.mat to case 163 so on.....Thank you in advance ....

采纳的回答

Stephen23
Stephen23 2022-1-24
编辑:Stephen23 2022-1-24
P = 'absolute or relative path to where the files are saved':
S = dir(fullfile(P,'*.mat'))
for k = 1:numel(S)
[~,N,~] = fileparts(S(k).name);
D = fullfile(P,N);
F = fullfile(P,S(k).name);
mkdir(D) % optional
movefile(F,D)
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by