Added functionality to remove empty notebooks/sections
This commit is contained in:
@@ -5,6 +5,13 @@ function delete(){
|
|||||||
if [ -e "$NOTES_DIR/$NOTE" ]; then
|
if [ -e "$NOTES_DIR/$NOTE" ]; then
|
||||||
rm "$NOTES_DIR/$NOTE"
|
rm "$NOTES_DIR/$NOTE"
|
||||||
printf " - %s\n" "Deleted note: ${NOTE%.*}."
|
printf " - %s\n" "Deleted note: ${NOTE%.*}."
|
||||||
|
#Cleanup empty notebooks/sections]
|
||||||
|
find "$NOTES_DIR" -mindepth 1 -type d | tac |\
|
||||||
|
while read -r DIR ; do
|
||||||
|
if [ ! "$(ls -A $DIR)" ]; then
|
||||||
|
rmdir "$DIR"
|
||||||
|
fi
|
||||||
|
done
|
||||||
else
|
else
|
||||||
>&2 printf " $RED_COLOR!$RESET_COLOR %s\n" "Note ${NOTE%.*} does not exist."
|
>&2 printf " $RED_COLOR!$RESET_COLOR %s\n" "Note ${NOTE%.*} does not exist."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user