Rename a file by changing only its file type
The command denote-change-file-type-and-front-matter provides the convenience of converting a note taken in one file type, say, ‘.txt’ into another like ‘.org’. It presents a choice among the denote-file-type options.
The conversion does NOT modify the existing front matter. Instead, it prepends new front matter to the top of the file. We do this as a safety precaution since the user can, in principle, add arbitrary extras to their front matter that we would not want to touch.
If in Dired, denote-change-file-type-and-front-matter operates on the file at point, else the current file, else it prompts with minibuffer completion for one.
The title of the file is retrieved from a line starting with a title field in the file’s front matter, depending on the previous file type (e.g. ‘#+title’ for Org). The same process applies for keywords.
As a final step, the command asks for confirmation, showing the difference between old and new file names.
This command constructs the file name in accordance with the user option denote-file-name-components-order (Change the order of file name components).