🐛 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
11
rmdir-empty
11
rmdir-empty
|
|
@ -9,9 +9,18 @@ rmdir_empty() {
|
|||
|
||||
# do the first level directories first
|
||||
for maxdepth_opt in "-maxdepth 1" ""; do
|
||||
find "$@" -depth -mindepth 1 $maxdepth_opt \
|
||||
for d in "$@"; do
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
rmdir_empty "$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue