CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   how to delete all folders of same type? (https://www.cfd-online.com/Forums/openfoam-post-processing/119301-how-delete-all-folders-same-type.html)

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,
Bruno

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:
Code:

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

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:
Code:

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?
Code:

for a in *; do rmdir $a; done

wyldckat June 20, 2013 16:41

Hi Ehsan,

It's the same as doing:
Code:

for a in *
do
    rmdir $a
done

To know more about each command:
Code:

help for
man rmdir

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

    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,
Bruno


All times are GMT -4. The time now is 03:16.