Prune all content

This commit is contained in:
tdehaeze committed 2026-10-12 13:51:12 +02:00
1 parent 9c3bf36f36
commit 665774dd08
1 file changed
+14 -10
+14 -10
View File
@@ -1,20 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Remove content/zettels/*.md whose org source in ~/Cloud/brain no longer exists. # Remove content/<section>/*.md (zettels and bibliography) whose org source in ~/Cloud/brain no longer exists.
# Dry run by default; pass --delete to actually remove files. # Dry run by default; pass --delete to actually remove files.
set -euo pipefail set -euo pipefail
brain=~/Cloud/brain brain=~/Cloud/brain
zet="$(cd "$(dirname "$0")" && pwd)/content/zettels" content="$(cd "$(dirname "$0")" && pwd)/content"
sections=(zettels book phdthesis inbook techreport article inproceedings websites)
count=0 count=0
for md in "$zet"/*.md; do for section in "${sections[@]}"; do
name=$(basename "$md" .md) for md in "$content/$section"/*.md; do
[[ $name == _index ]] && continue [[ -e $md ]] || continue
if [[ ! -f "$brain/$name.org" ]]; then name=$(basename "$md" .md)
echo "orphan: $md" [[ $name == _index ]] && continue
[[ ${1:-} == --delete ]] && rm "$md" if [[ ! -f "$brain/$name.org" ]]; then
count=$((count + 1)) echo "orphan: $md"
fi [[ ${1:-} == --delete ]] && rm "$md"
count=$((count + 1))
fi
done
done done
if [[ $count -eq 0 ]]; then if [[ $count -eq 0 ]]; then