Prune all content
This commit is contained in:
1 parent
9c3bf36f36
commit
665774dd08
1 file changed
+7
-3
+7
-3
@@ -1,13 +1,16 @@
|
|||||||
#!/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
|
||||||
|
for md in "$content/$section"/*.md; do
|
||||||
|
[[ -e $md ]] || continue
|
||||||
name=$(basename "$md" .md)
|
name=$(basename "$md" .md)
|
||||||
[[ $name == _index ]] && continue
|
[[ $name == _index ]] && continue
|
||||||
if [[ ! -f "$brain/$name.org" ]]; then
|
if [[ ! -f "$brain/$name.org" ]]; then
|
||||||
@@ -15,6 +18,7 @@ for md in "$zet"/*.md; do
|
|||||||
[[ ${1:-} == --delete ]] && rm "$md"
|
[[ ${1:-} == --delete ]] && rm "$md"
|
||||||
count=$((count + 1))
|
count=$((count + 1))
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $count -eq 0 ]]; then
|
if [[ $count -eq 0 ]]; then
|
||||||
|
|||||||
Reference in new issue
Block a user