2015-01-29 3 views

답변

3

오늘 나는 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 
+0

감사합니다. kosta! 이것은 나에게도 효과가있다! 나머지 빈 서브 디렉토리를 삭제하려면'find $ datadir -depth -type d -empty -delete'를 추가하는 것이 좋습니다. – baruch

+0

검색에 .org_archive 파일을 포함 시키려면 9 행의 grep 명령에'--include "* .org_archive"를 추가하십시오. 그렇지 않으면 아카이브 된 항목의 첨부 파일도 고아로 처리됩니다. – baruch