CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Post-Processing (
-   -   how to delete all folders of same type? (

immortality June 13, 2013 15:43

how to delete all folders of same type?
whats the command to delete all folders of a postProcessing result in time folders after seeing and use?

wyldckat June 15, 2013 17:14

Hi Ehsan,

Sorry, but your question is too ambiguous :(
Can you describe in more detail?

Best regards,

immortality June 15, 2013 17:33

for example the folders that originated by "Co"(courant number) command.

wyldckat June 15, 2013 18:17

I've tested running Co with the tutorial case "incompressible/icoFoam/cavityGrade" and it only created the field files "Co" in the already existing time folders. To remove these field files, you can do the following command:

rm */Co
You can see what this command actually does, by running:

echo rm */Co

But if it does create new folders, them the trick should be to first remove the files that were created, by using the command above; and then remove the empty directories with the following command:

for a in *; do rmdir $a; done
It will give several messages indicating that certain files/folders cannot be removed, simply because they are not empty or are not folders. In other words, rmdir will only delete the empty folders.

immortality June 19, 2013 09:05

could you describe me a bit about it?

for a in *; do rmdir $a; done

wyldckat June 20, 2013 16:41

Hi Ehsan,

It's the same as doing:

for a in *
    rmdir $a

To know more about each command:

help for
man rmdir

In essence:
  • The asterisk lists all files and folders in the current folder. You can see this if you run:

    echo *
  • rmdir removes empty directories.
  • "for" is ... it is a for cycle!? Not sure how to explain this one, since it's command to several programming languages.
For more information on how to program in the bash shell... Google? ;)

Best regards,

All times are GMT -4. The time now is 15:57.