필터 지우기
필터 지우기

Logic to copy files into specific locations

조회 수: 1 (최근 30일)
Aadil
Aadil 2012년 8월 30일
Hi there,
I need some help with creating a script that can copy and sort files into there respective folders.
1. I have a script that creates matfiles daily and sorts them into monthly folders. 2. These matfiles then need to be copied into a different location which contains folders created by day
I have included a screen shot for better understanding
Any help with what sort of logic I would need to use would be much appreciated.
Thanks,

채택된 답변

Davide Ferraro
Davide Ferraro 2012년 8월 30일
Hi,
This is a possible approach:
files = dir('*.mat');
for i = 1:length(files)
datefolder = files(i).name(14:19);
mkdir(getdate)
copyfile('files(i).name',datefolder)
end
With the DIR command you get the names of the files in your folder (eventually you can also select wich file extension you want). With a simple loop you extract the date from the file name (based on your file this seems to be always in the same position so you only need to find the portion of your vection to extract). You may use this information to create the new folder (eventually reshaping it adding dashes or inverting the terms) and then with COPYFILE you can copy the file in the new folder.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by