필터 지우기
필터 지우기

How to assign different files in the target folders?

조회 수: 1 (최근 30일)
Ashfaq Ahmed
Ashfaq Ahmed 2022년 3월 8일
댓글: Ashfaq Ahmed 2022년 3월 9일
Hi all!
Suppose, I have several files in a folder named like this:
Please note that 20150408 means 2015-April-08.
Now I want to write a code that will go through all these files and will generate folders for each of the day in the same directory. For example, all the files that contains day 08's data with be moved to a folder named "Day08". Similarly, for day 09's data, it will be in "Day09" folder. I have a months of data and it contains files from day 01 to day 31.
Could you please give me an idea on how to efficiently write this code?

채택된 답변

Stephen23
Stephen23 2022년 3월 8일
P = 'absolute or relative path to where the files are saved';
for k = 1:31
D = sprintf('Day%02d',k);
mkdir(P,D)
X = fullfile(P,sprintf('*%02dT*.nc',k));
Y = fullfile(P,D);
movefiles(X,Y)
end
  댓글 수: 1
Ashfaq Ahmed
Ashfaq Ahmed 2022년 3월 9일
Hi! Thanks for the code. Unfortunately, it says
Unrecognized function or variable 'movefiles'.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by