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 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!