forked from precice/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenfoam-remove-empty-dirs.sh
executable file
·27 lines (25 loc) · 1.13 KB
/
openfoam-remove-empty-dirs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /bin/sh
# Cleaning up stray functionObjectProperties files, see https://github.com/precice/openfoam-adapter/issues/26
openfoam_remove_empty_dirs() {
(
set -e -u
echo "Cleaning up any time directories without results"
for f in [0-9]* [0-9]*.[0-9]*; do
if ! [ -f "${f}/U" ] && ! [ -f "${f}/T" ] && ! [ -f "${f}/U.gz" ] && ! [ -f "${f}/T.gz" ] && ! [ -f "${f}/D" ] && ! [ -f "${f}/pointD" ] && ! [ -f "${f}/DD" ] && ! [ -f "${f}/pointDD" ] && ! [ -f "${f}/D.gz" ] && ! [ -f "${f}/pointD.gz" ] && ! [ -f "${f}/DD.gz" ] && ! [ -f "${f}/pointDD.gz" ]; then
rm -rf "${f}"
fi
done
if [ -d processor0 ]; then
for d in processor*; do
cd "${d}"
for f in [0-9]* [0-9]*.[0-9]*; do
if ! [ -f "${f}/U" ] && ! [ -f "${f}/T" ] && ! [ -f "${f}/U.gz" ] && ! [ -f "${f}/T.gz" ] && ! [ -f "${f}/D" ] && ! [ -f "${f}/pointD" ] && ! [ -f "${f}/DD" ] && ! [ -f "${f}/pointDD" ] && ! [ -f "${f}/D.gz" ] && ! [ -f "${f}/pointD.gz" ] && ! [ -f "${f}/DD.gz" ] && ! [ -f "${f}/pointDD.gz" ]; then
rm -rf "${f}"
fi
done
cd ..
done
fi
echo "Done."
)
}