Moving Bulk MATLAB file to different folders

조회 수: 4 (최근 30일)
Prasad Joshi
Prasad Joshi 2022년 1월 24일
편집: Prasad Joshi 2022년 1월 24일
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
  댓글 수: 1
Prasad Joshi
Prasad Joshi 2022년 1월 24일
편집: Prasad Joshi 2022년 1월 24일
Thank you Stephen ...The code work and was able to sort also ...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by