Open baogiadoan opened 2 years ago
I'm afraid there's currently no such functionality implemented in org-journal.
But if anyone wants to contribute a function or external script, I'll happily accept a pull request.
Hi, I just converted daily files to monthly like this:
;;; -*- lexical-binding: t -*-
(require 'org)
(require 'org-refile)
(require 'org-journal)
(require 'cl-lib)
;; Step 1: convert
(org-map-entries
(lambda ()
(let* ((original (file-name-base (buffer-file-name)))
(year (substring original 0 4))
(month (substring original 4 6))
(day (substring original 6 8))
(new-ts (format-time-string org-journal-created-property-timestamp-format
(encode-time (org-parse-time-string (format "%s-%s-%s" year month day)))))
(dest (expand-file-name (concat year month ".org")
(file-name-directory (buffer-file-name))))
(org-refile-keep t))
(cl-labels ((post-refile ()
(org-set-property "CREATED" new-ts)
(save-buffer)))
(let ((org-after-refile-insert-hook (list #'post-refile)))
(org-refile nil nil `("fake-toplevel-heading" ,dest nil nil))))))
"LEVEL=1"
(directory-files org-journal-dir t (rx bos (= 8 digit) ".org" eos)))
;; Step 2: delete original dailies after reviewing results.
(seq-do #'delete-file
(directory-files org-journal-dir t (rx bos (= 8 digit) ".org" eos)))
This isn't quite polished enough to merge as is, but it's really close if anyone wants to finish it up. I think these are the only assumptions that need to be fixed:
yyyymmdd.org
(see directory-files
regexp arg).yyyymm.org
(see dest
variable). Should use org-journal-file-format
to create the destination file name instead.Wonderful, thank you! Would you like to add it to the README as a code example of how to do this sort of thing?
I don't have time to put together a pull request, sorry... my comment was just a quick drive-by for posterity. You're welcome to put it in the readme or use it however you'd like though.
Hi Caleb,
Thanks for your contribution, I'm much appreciated if you can modify the code to include the yearly file as well and write a README and code example like Bastian's suggestion.
On Tue, 21 Jun 2022 at 16:17, Bastian Bechtold @.***> wrote:
Wonderful, thank you! Would you like to add it to the README as a code example of how to do this sort of thing?
— Reply to this email directly, view it on GitHub https://github.com/bastibe/org-journal/issues/386#issuecomment-1161330606, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFZFNFHAY3UQEDLJDCYD23VQFQQDANCNFSM5SUP2XNQ . You are receiving this because you authored the thread.Message ID: @.***>
-- Best regards, Bao
Is your feature request related to a problem? Please describe.
The problem is that I used Org-journal for a long time and my setting for org-journal is
'daily
which means that I have a lot of separate files now; however, my need changes and I used'yearly
as the moment; however, I can't see how I still keep the old journals (i.e. convert them into a yearly files)Describe the solution you'd like
A function to convert the daily files into a single yearly file compatible with the current `yearly that I set up