-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to rename directories using the denote format? #520
Comments
From: Maikol Solís ***@***.***>
Date: Mon, 6 Jan 2025 10:59:02 -0800
Basically, this is the question. Suppose you have directories
```
A
B
C
```
And you want to rename them into something like
```
20250106T000001--a
20250106T000002--b
20250106T000003--c
```
It tried with `denote-rename-file` in dired, but it didn't work.
What do you think about this feature?
Technically, we can make it happen. Do you have a use-case for
identifiers in directory names? Will you be linking to them directly,
instead of to files, for example? This should work, as 'find-file' on a
directory will open it in Dired. I am just curious to understand the
workflow better.
…--
Protesilaos Stavrou
https://protesilaos.com
|
Hi Prot. Yes, maybe my use case could be not so common, but I use a PARA system to organize my files. In particular, I want to organize my projects by date of creation. I write manually my folder with this structure (inspired by the denote nomenclature)
My idea was to create a silo in my projects folder and see if I could use denote to rename those folders easily. This way all my projects could be archived in order when they are finished. I don't know whether the idea has potential or not, perhaps other users could give their insights. Best. |
I see, thank you for the explanation! I am not sure we should go down this path. But maybe we can post the code here and interested parties will share their thoughts. Maybe there is no good reason for us to only accept regular files. First you need this diff on top of the current commit ( denote.el | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/denote.el b/denote.el
index 678d805..d035a1e 100644
--- a/denote.el
+++ b/denote.el
@@ -3097,7 +3097,8 @@ (defun denote-rename-file-and-buffer (old-name new-name)
(unless (string= (expand-file-name old-name) (expand-file-name new-name))
(if (denote--file-type-org-extra-p)
(setq denote-last-path-after-rename new-name)
- (when (and (file-regular-p old-name)
+ (when (and (or (file-regular-p old-name)
+ (file-directory-p old-name))
(file-writable-p new-name))
(cond
((derived-mode-p 'dired-mode)
@@ -3403,10 +3404,7 @@ (defun denote--rename-dired-file-or-current-file-or-prompt ()
(format "Rename FILE Denote-style [%s]: " file)
"Rename FILE Denote-style: "))
(selected-file (read-file-name format nil file t nil)))
- (if (or (file-directory-p selected-file)
- (not (file-regular-p selected-file)))
- (user-error "Only rename regular files")
- selected-file))))
+ selected-file)))
(defun denote-rename-file-prompt (old-name new-name)
"Prompt to rename file named OLD-NAME to NEW-NAME.
@@ -3478,7 +3476,8 @@ (defun denote--rename-file (file title keywords signature date)
(date (if (string-empty-p id) nil (date-to-time id)))
(new-name (denote-format-file-name directory id keywords title extension signature))
(max-mini-window-height denote-rename-max-mini-window-height))
- (when (and (file-regular-p new-name)
+ (when (and (or (file-regular-p new-name)
+ (file-directory-p new-name))
(not (string= (expand-file-name file) (expand-file-name new-name))))
(user-error "The destination file `%s' already exists" new-name))
;; Modify file name, buffer name, or both Then you can write a small wrapper function like this one to do what you want: (defun my-denote-rename-folder ()
(interactive)
(let ((denote-prompts '(date title)))
(call-interactively 'denote-rename-file))) |
Interesting idea ! They are multiple emacs people that use PARA or JohnyDecimal with Org. And even crazyiest guy (like me?) try to mix both systems (PARA + Johny.Decimal). In both methods, folder and subfolder naming or tagging are really important. For my use case i decide to follow Denote template + Johny.Decimal like using |
Basically, this is the question. Suppose you have directories
And you want to rename them into something like
It tried with
denote-rename-file
in dired, but it didn't work.What do you think about this feature?
Best.
The text was updated successfully, but these errors were encountered: