emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Splitting large org file into smaller ones


From: John Kitchin
Subject: Re: Splitting large org file into smaller ones
Date: Sun, 31 May 2020 11:29:29 -0400
User-agent: mu4e 1.3.6; emacs 26.3

This seems like an important thing to get right, so I would hesitate to
do this very automatically.

I would write a function that does what you want, maybe like this:

#+BEGIN_SRC emacs-lisp
(defun subtree-to-file ()
  (interactive)
  (org-narrow-to-subtree)
  (goto-char (point-min))
  (let* ((heading (fifth (org-heading-components)))
         (fname (concat (mapconcat 'downcase (split-string heading) "-") 
".org")))
    (when
        (y-or-n-p (format "Write subtree to %s" fname))
      (org-cut-subtree)
      (with-temp-file fname
        (org-yank))))
  (widen)
  (when (not (org-at-heading-p))
    (org-next-visible-heading 1)))
#+END_SRC

This will generate filenames based on the heading name, and move the
content to that file if you agree with the filename. It does not check
if the fname exists, which may be a good idea. It does not do anything
fancy like promote the heading, it just moves it.

It is a good idea to do this on a copy of the original file, so that you
have an un-altered version in case it does not go as planned.


Marvin M. Doyley <mdoyley@ur.rochester.edu> writes:

> Hi there,
>
> Is there an efficient way to split a large org file into smaller ones?
>
> Lets say I have a master file with the following
>
>
> * Notes
> **  Candidate A
>  - Strong technical background
>  - High H-factor
>  - good funding
> - More established investigator
> - Huge startup need $$
>
> **  Candidate B
> - lower startup need
> - signal processing
> - young investigator
>
>
> How do I export the subtree to separate org files, say
>
> - Candidate-a.org <http://candidate-a.org/>
> - Candidate-b.org <http://candidate-b.org/>
>
>
> Thanks
>
> M


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]