-
Notifications
You must be signed in to change notification settings - Fork 79
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
Syntax to create subdirectories for each org file: (setq-default org-download-image-dir "./img/?") #195
Comments
Duplicate of #46 A slightly better function that creates separate folders for each org file. (defun my-org-download-method (link)
(let ((filename
(file-name-nondirectory
(car (url-path-and-query
(url-generic-parse-url link)))))
(dirname (concat "./img/" (file-name-sans-extension (file-name-nondirectory (buffer-file-name))))))
(setq org-download-image-dir dirname)
(make-directory dirname t)
(expand-file-name filename dirname)))
(setq org-download-method 'my-org-download-method) |
Thanks! Haven't tried it yet. What names would the directories within img/ have? |
The current org buffer file name where you're inserting the image. |
Thank you! So at the moment in my init I have these two lines regarding org-download:
Shall I replace both with just
I suppose the line |
You would include the function defintion for
Yes, not necessary. |
I just tried this but it doesn't create subdirectories within /img eg., |
Ensure that there is a trailing slash after "./img/" in this line (dirname (concat "./img/" (file-name-sans-extension (file-name-nondirectory (buffer-file-name)))))) |
Yes! My bad! Thanks again! |
Hi, I encountered an issue with this: now my screenshots are named So when I paste a second screenshot... it tells me there is already a Before it used to name every screenshot prepending the date plus time: |
Any advice on this? Thanks! |
@pirattidasan Thank you. Tried you code. It works. However, the display of image size changes. In the default setting where the I'm using doom emacs. I'm not sure whether the image size is defined in doom or by the org-attach itself. Some idea about this? |
(defun my-org-download-method (link)
(let ((filename
(file-name-nondirectory
(car (url-path-and-query
(url-generic-parse-url link)))))
(dirname (concat "./org-download-imgs/" (file-name-sans-extension (file-name-nondirectory (buffer-file-name))))))
(setq org-download-image-dir dirname)
(make-directory dirname t)
(expand-file-name (funcall org-download-file-format-function filename) dirname)))
(setq org-download-method 'my-org-download-method) |
doesn't work (defun my-org-download-method (link)
(let ((dirname (concat (file-name-sans-extension (buffer-file-name)) "-images")))
(setq org-download-image-dir dirname)
(make-directory dirname t)
))
(setq org-download-method 'my-org-download-method) |
What would be the syntax to create separate directories withint an /img directory for each orgmode buffer? This would allow a cleaner organization of images (not having all images in one directory).
This creates a directory /img where all images would go:
(setq-default org-download-image-dir "./img")
The text was updated successfully, but these errors were encountered: