trganda / obsidian-attachment-management

Attachment Management of Obsidian
MIT License
142 stars 8 forks source link

${originalname} seems to be broken #87

Open OsoRojo opened 6 months ago

OsoRojo commented 6 months ago

I'm unable to use ${originalname} in conjunction with any other format parameters. In fact it seems to just not work at all.

Example:

Image file named "foo.jpg" Attachment format of: ${originalname} - ${date} Result: foo-1.jpg

Additionally, originalname doesn't appear to be supported in extension overrides, which is where I really need them the most. At least the dialog doesn't list it as an option, and it definitely doesn't work. I don't know if this is intended or an oversight.

trganda commented 6 months ago

I'm unable to use ${originalname} in conjunction with any other format parameters. In fact it seems to just not work at all.

Looks like the ${date} was not working right. Can you provide your setting (a data.json file in .obsidian/plugins/attachment-management) of this plugin?

I have tested your example, it's work.

image

Additionally, originalname doesn't appear to be supported in extension overrides

I have forgot to update the description, your can also use ${originalname} in overrides.

OsoRojo commented 6 months ago

See attached. I just removed the plugin and reinstalled, and I'm getting the same result. Extension overrides that include date as noted above just result with the original filename (which is good) and a '-1' at the end instead of the filename (which is bad).

Also, as previously noted using originalname either isn't working, OR it cannot be combined with other options. I just tested that again in the base settings (not an extension override) and it moves the file fine, but no renaming occurs. Use case: ${originalname} - ${date}

data.json

OsoRojo commented 6 months ago

I should have noted, this is occurring when I'm running the rearrange attachments command, NOT on attachment insertion (paste). I just noticed that the combination of ${originalname} - ${date} does appear to work when pasting in images, but not when running the rearrange attachments command.

trganda commented 6 months ago

The variable ${originalname} has a flaw, since I have not presist the origianl name of an attachment when it was added to notes. When you add an attachment to ob, we could simply know the name of the attachment. But in the rename (rearrange) operation, this plugin didn't know the origanl name and just return current name (ignore all variable). The suffix -1 was added for deduplicate.

I will make a PR to complete the implemention of ${originalname}. You can temporarily disable this plugin if other variable was not meet your needs.

OsoRojo commented 6 months ago

It seems to me in this case that using the current name as the original name would probably make the most sense. At least, that's the behavior I was sort of expecting. Glad that the additional context (rearrange vs. new insertion) helped to sort it out!

Loving the plugin so far. Just trying to find the best way to leverage it!

Thanks!