🐛 rmdir-empty: directory might have been removed in the first level round
This commit is contained in:
parent
3b21559014
commit
4ae427ef45
1 changed files with 11 additions and 2 deletions
13
rmdir-empty
13
rmdir-empty
|
|
@ -9,8 +9,17 @@ rmdir_empty() {
|
||||||
|
|
||||||
# do the first level directories first
|
# do the first level directories first
|
||||||
for maxdepth_opt in "-maxdepth 1" ""; do
|
for maxdepth_opt in "-maxdepth 1" ""; do
|
||||||
find "$@" -depth -mindepth 1 $maxdepth_opt \
|
for d in "$@"; do
|
||||||
-type d -empty -exec rmdir -v {} \;
|
|
||||||
|
# directory might have been removed in the first level round
|
||||||
|
if [ -z "$max_depth_opt" -a ! -e "$d" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
find "$d" -depth $maxdepth_opt \
|
||||||
|
-path "." -prune -or \
|
||||||
|
-type d -empty -exec rmdir -v {} \;
|
||||||
|
done
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue