Skip to content
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

[Feature]Allow folder creation. #83

Open
LemonPrefect opened this issue Dec 26, 2023 · 1 comment
Open

[Feature]Allow folder creation. #83

LemonPrefect opened this issue Dec 26, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@LemonPrefect
Copy link

Is your feature request related to a problem? Please describe.
When trying to store and manage all the images, the attachments are too many to be find as all the images are stored in the same folder. So I've been wanted the plugin to save the images seperately in different folders by document with the imageNameKey given as a parent folder name. But the plugin keeps saying folder not found.

Describe the solution you'd like
Maybe try to create folders before trying to call move.

@@ -159,6 +160,9 @@ export default class PasteImageRenamePlugin extends Plugin {
		// file system operation: rename the file
		const newPath = path.join(file.parent.path, newName)
		try {
+			const newBase = newPath.slice(0, -(path.basename(newPath).length))
+			if (!(await this.app.vault.adapter.exists(newBase, true)))
+				await this.app.vault.createFolder(newBase)
			await this.app.fileManager.renameFile(file, newPath)
		} catch (err) {
			new Notice(`Failed to rename ${newName}: ${err}`)

Describe alternatives you've considered
Not found yet.

Additional context
None

@LemonPrefect LemonPrefect added the enhancement New feature or request label Dec 26, 2023
@antnesswcm
Copy link

请问问题解决了吗,我现在很痛苦,现在是否可以将图片保存到指定的文件夹中,文件夹不存在也可以创建,不会提示 没有那个文件或目录

May I ask if the problem has been resolved? I am in a lot of pain now
Can I save the images to the specified folder now? If the folder does not exist, it can still be created without prompting that there is no file or directory available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants