mkdir from Dymola mos script

落花浮王杯 提交于 2021-01-28 02:03:17

问题


I have a mos script for running multiple simulations. Before running a simulation, I want to cd to a new directory, so that all result and log files are saved and never overwritten. Currently it is only possible to cd to existing directories, as far as I know. Anybody has a recommendation how to create a directory named e.g. temp_modelname and cd to that directory from a mos script? I could use mkdir in a system call, or is there a convenience wrapper prepared and I just missed it?

EDIT: BAsed on the answer given below, this is my current solution:

// cd to temporary directory temp_XYZ
i = 1;
tempDirName = home + "/Documents/Dymola/temp_" + String(i, format="03G");
while Modelica.Utilities.Files.exist(tempDirName) loop
    i=i+1;
    tempDirName = home + "/Documents/Dymola/temp_" + String(i, format="03G");
end while;
Modelica.Utilities.Files.createDirectory(tempDirName);
cd(tempDirName);

回答1:


The utilities package contains a function to create directories recursively:

Modelica.Utilities.Files.createDirectory("temp_modelname")


来源:https://stackoverflow.com/questions/54764226/mkdir-from-dymola-mos-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!