问题
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