CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Post-Processing (
-   -   how to put time folders in a unique folder (

immortality August 13, 2013 10:28

how to put time folders in a unique folder
when run is doing a lot of time folders originate in the root folder of case.
in such situation may it take a lot of time to find essential folders 0,constant and system or maybe delete them mistakenly with other folders.
how can have time folders in a separate folder?
is there a script for this purpose?

Bernhard August 13, 2013 11:39

What do you mean with find the essential folders? From the shell it is just "cd folder" right?

Did you consider improving your work flow with utilities and

You can improve one of these utlities to do what you want. It seems not too difficult, add some function to the SolutionDirectory class, and create a new instance of this class in some fancy utility :)

Or, of course you could try to move it with bash and fancy regular expressions. :)

immortality August 13, 2013 11:52

Hi Bernhard
none of them! I meant main folders that are :0,constant and system.
I mean that if all other time folders could be written in a separate folder we had a more well-ordered case folder,then we had this folders:0,constant,system,time_folder
that time_folder is a folder that includes all time folders after 0 time.
do you mean I can do this by Swak utilities?

ngj August 13, 2013 13:27

If you are really, really, really sure that you want to do this, then try the following, which ought to work:


mkdir time_folders
list=`ls -d [0-9]* | grep -v "^0$"`
mv $list time_folders/.

Kind regards


immortality August 13, 2013 14:00

Hi Niels
thanks for the script but I like a way that it can be done automatically with the solver itself. :)

ngj August 13, 2013 14:07

If that should be done nicely, then it means that you need to change the core of OpenFoam. Also, you would need to modify paraFoam/ParaView to be able to visualise data.

Depending on how you approach the above, you might need to put "if's" into all utilities/solvers, as the 0-folder and all other time folders have a different relative path to the root-case directory.

Shortly: Why don't you merely learn to work with the existing file structure?

Kind regards


immortality August 13, 2013 14:17

then there is a lot of work to do that.I just said that it would be better if the root folder was less crowded! whats your opinion?
I think maybe they do it in later releases.

pad August 14, 2013 02:59

Maybe you could use a function object with your controlDict. I use this with some success to reduce the number of files created at runtime to only the latest.

type systemCall;
functionObjectLibs ( "" );
executeCalls 0();
endCalls 0();
writeCalls 2("ls -1td $PWD/_impellerSurfacePressure/* | tail -n +3 | xargs echo rm -rf" "ls -1td $PWD/_impellerSurfacePressure/* | tail -n +3 | xargs rm -rf");
outputControl outputTime;
// outputInterval 10;

immortality August 14, 2013 04:39

seems be nice,could you explain its lines a bit to me?thanks.

pad August 14, 2013 05:03

Typing --help after the different linux commands usually gets you a long way in linux.

It may be faster for you to try the lines below than me trying to explain.

ls -1td <OF case folder>
ls -1td <OF case folder> | tail -n +3 (try varying the number 3)
ls -1td <OF case folder> | tail -n +3 | xargs echo rm -rf (echo just ensures that you don't delete anything by mistake)

The above is called twice in my function object just to get some output with 'echo'. Not the most beautiful approach but it worked for me.

Regarding function object see

All times are GMT -4. The time now is 09:37.