gpt4 book ai didi

emacs - 如何从光盘中删除未使用的 org-mode 附件文件

转载 作者:行者123 更新时间:2023-12-01 09:27:09 25 4
gpt4 key购买 nike

在 org-mode 中,删除了很多带有附件的标题后,未引用的文件现在保留在我的数据子目录中的光盘上。

是否有函数或脚本可以找到所有未引用的文件并进行清理?

最佳答案

今天我在处理 org-capture-templates 之后遇到了同样的问题,然后删除了一堆没有按照我想要的方式出现的条目。

我写下了这个脚本,它完成了工作(对我来说)。

#!/bin/sh

## Location where org-mode stores attachments
datadir="$HOME/Dropbox/Documents/Org/data";
orgdir="$HOME/Dropbox/Documents/Org/"

echo "The following files appear orphaned:";

files=$(find "$datadir" -type f|perl -ne 'print "$1\n" if /([^\/]*)\/[^\/]*$/'|uniq|while read id; do grep -qiR --include "*.org" "$id" "$orgdir" || find "$datadir" -ipath "*$id*" -type f; done)

echo "$files"

if [ "" == "$files" ]; then
echo "Nothing to do!"
exit
fi

echo "Delete? y/[n]"
read delete
case $delete in
y)
echo "$files" |
while read fn; do
rm "$fn";
done
echo "Done."
;;
*)
echo "Not deleting anything!"
;;
esac

关于emacs - 如何从光盘中删除未使用的 org-mode 附件文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28213360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com