Move files to a new folder for every model run
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm looking for a solution where after running the executable I can store some newly created files for example, newfile_1.txt, newfile_2.txt to a new folder (Run_1, Run_2...) for every run. I can only create one folder which overwrites the moved files after every run.
% set working directory
cd('E:\Tutorial\SimFolder\');
runpath = 'E:\Tutorial\SimFolder\';
myDir = 'E:\Tutorial\New_Files\'; %gets directory of files to be copied
myFiles = dir(fullfile(myDir,'*.txt')); %gets all txt files in struct e.g. file_1.txt, file_2.txt...
for k = 1:length(myFiles)
baseFileName = myFiles(k).name;
fullFileName = fullfile(myDir, baseFileName);
copyfile(fullFileName,[runpath 'file.txt']); %copy & rename file for every run
system('program.exe'); %run executable
movefile([runpath 'newfile_1.txt'],'E:\Tutorial\Results\Run_1'); %this part needs to change
end
댓글 수: 0
답변 (1개)
Rik
2017년 4월 21일
You mean something like this?
movefile([runpath sprintf('newfile_%d.txt',run_number)],sprintf('E:\\Tutorial\\Results\\Run_%d',run_number));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!