Skip to content

Rename multiple files at once by asking only for keywords

The denote-dired-rename-marked-files-with-keywords command renames marked files in Dired to conform with our file-naming scheme. It does so by writing keywords to them. Specifically, it does the following:

  • retains the file’s existing name and makes it the ‘TITLE’ field, per Denote’s file-naming scheme;
  • sluggifies the ‘TITLE’ and adjusts its letter casing, according to our conventions;
  • prepends an identifier to the ‘TITLE’, if one is missing;
  • preserves the file’s extension, if any;
  • prompts once for ‘KEYWORDS’ and applies the user’s input to the corresponding field in the file name, rewriting any keywords that may exist while removing keywords that do exist if ‘KEYWORDS’ is empty;
  • adds or rewrites existing front matter to the underlying file, if it is recognized as a Denote note (per the denote-file-type user option), such that it includes the new keywords.

[ Note that the affected buffers are not saved, unless the user option denote-rename-no-confirm is non-nil. Users can thus check them to confirm that the new front matter does not cause any problems (e.g. with the diff-buffer-with-file command). Multiple buffers can be saved in one go with the command save-some-buffers (read its doc string). ]

Construct the file name in accordance with the user option denote-file-name-components-order (Change the order of file name components).

Run the denote-after-rename-file-hook after the renaming is done.

For more specialized versions of this command that only add or remove keywords, use denote-dired-rename-marked-files-add-keywords and denote-dired-rename-marked-files-remove-keywords, respectively.