Add ensure_newline_ending.py and run_full_cleanup.sh master script
This commit is contained in:
parent
144b6c917a
commit
578312e380
2 changed files with 229 additions and 0 deletions
79
run_full_cleanup.sh
Executable file
79
run_full_cleanup.sh
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Logseq Full Cleanup Runner
|
||||
#
|
||||
# Runs all cleanup scripts in the correct order to normalize Logseq journal files.
|
||||
#
|
||||
# Order of operations:
|
||||
# 1. Remove Task List query blocks (largest changes first)
|
||||
# 2. Remove empty bullet lines (cleanup remnants)
|
||||
# 3. Ensure single trailing newline (final normalization)
|
||||
#
|
||||
# Usage:
|
||||
# ./run_full_cleanup.sh [--dry-run] <path>
|
||||
#
|
||||
# Examples:
|
||||
# ./run_full_cleanup.sh --dry-run ~/notes_test/journals/
|
||||
# ./run_full_cleanup.sh ~/notes_test/journals/2026_10_23.md
|
||||
# ./run_full_cleanup.sh -r ~/notes_test/journals/
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DRY_RUN=""
|
||||
RECURSIVE=""
|
||||
TARGET=""
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--dry-run)
|
||||
DRY_RUN="--dry-run"
|
||||
shift
|
||||
;;
|
||||
-r)
|
||||
RECURSIVE="-r"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
TARGET="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$TARGET" ]; then
|
||||
echo "Error: No target path specified"
|
||||
echo "Usage: $0 [--dry-run] [-r] <path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=========================================="
|
||||
echo "Logseq Full Cleanup"
|
||||
echo "=========================================="
|
||||
echo "Target: $TARGET"
|
||||
[ -n "$DRY_RUN" ] && echo "Mode: DRY RUN (no changes will be made)"
|
||||
echo ""
|
||||
|
||||
# Step 1: Remove Task List query blocks
|
||||
echo "Step 1/3: Removing Task List query blocks..."
|
||||
echo "-------------------------------------------"
|
||||
python3 "$SCRIPT_DIR/clean_task_lists.py" $DRY_RUN $RECURSIVE "$TARGET"
|
||||
echo ""
|
||||
|
||||
# Step 2: Remove empty bullet lines
|
||||
echo "Step 2/3: Removing empty bullet lines..."
|
||||
echo "-------------------------------------------"
|
||||
python3 "$SCRIPT_DIR/clean_empty_bullets.py" $DRY_RUN $RECURSIVE "$TARGET"
|
||||
echo ""
|
||||
|
||||
# Step 3: Ensure single trailing newline
|
||||
echo "Step 3/3: Ensuring single trailing newline..."
|
||||
echo "-------------------------------------------"
|
||||
python3 "$SCRIPT_DIR/ensure_newline_ending.py" $DRY_RUN $RECURSIVE "$TARGET"
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "Cleanup complete!"
|
||||
echo "=========================================="
|
||||
Loading…
Add table
Add a link
Reference in a new issue