如何将一文件夹中的所有ORG文件和TXT文件加载到AGENDA中

如题,不想一个一个手动加,有没有办法把某一文件夹下的文件自动加进agenda file里 :grin:

应该在这后面加什么 `[^.].*.org’

(defcustom org-agenda-files nil
  "The files to be used for agenda display.

If an entry is a directory, all files in that directory that are matched
by `org-agenda-file-regexp' will be part of the file list.

If the value of the variable is not a list but a single file name, then
the list of agenda files is actually stored and maintained in that file,
one agenda file per line.  In this file paths can be given relative to
`org-directory'.  Tilde expansion and environment variable substitution
are also made.

Entries may be added to this list with `\\[org-agenda-file-to-front]'
and removed with `\\[org-remove-file]'."
  :group 'org-agenda
  :type '(choice
	  (repeat :tag "List of files and directories" file)
	  (file :tag "Store list in a file\n" :value "~/.agenda_files")))

所以把那个目录add-to-list进去就行

楼上的方法没试过,我是这样用的

(setq org-agenda-files (directory-files-recursively "~/org/" "\\.org$"))

还想把文件夹下的TXT文档加进去

小白能问一下具体怎么加么 加了后能把文件夹下的TXT文档也识别进去吗

要包括TXT,把最后的正则参数换一下 "\\.org$\\|\\.txt$"

不过注意一点,这个方法会把文件夹里的子目录都扫描了。

好的 谢谢你 可以了

正则应该用(rx (or ".org" ".txt") eos),因为换行符可以作为文件名一部分

2 个赞

学到了rx :+1:,正则还可以这样写