Rename a single file based on its front matter
In the previous section, we covered the more general mechanism of the command denote-rename-file (Rename a single file). There is also a way to have the same outcome by making Denote read the data in the current file’s front matter and use it to construct/update the file name. The command for this is denote-rename-file-using-front-matter. It is only relevant for files that (i) are among the supported file types, per denote-file-type, and (ii) have the requisite front matter in place.
Suppose you have an ‘.org’ file with this front matter (Front matter):
#+title: My sample note file
#+date: [2022-08-05 Fri 13:10]
#+filetags: :testing:
#+identifier: 20220805T131044Its file name reflects this information:
20220805T131044--my-sample-note-file__testing.orgYou want to change its title and keywords manually, so you modify it thus:
#+title: My modified sample note file
#+date: [2022-08-05 Fri 13:10]
#+filetags: :testing:denote:emacs:
#+identifier: 20220805T131044At this stage, the file name still shows the old title and keywords. You now invoke denote-rename-file-using-front-matter and it updates the file name to:
20220805T131044--my-modified-sample-note-file__testing_denote_emacs.orgBy default, the renaming is subject to a “yes or no” prompt that shows the old and new names, just so the user is certain about the change. Though this can be modified (The denote-rename-confirmations option).
The identifier of the file, if any, is never modified even if it is edited in the front matter: Denote considers the file name to be the source of truth in this case, to avoid potential breakage with typos and the like.
This command constructs the file name in accordance with the user option denote-file-name-components-order (Change the order of file name components).