trganda / obsidian-attachment-management

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

How to rename remove space? #111

Open roytoh opened 3 months ago

roytoh commented 3 months ago

I tested ${originalname.replace(/\s/g, '')}

But still can't remove space from original file name

roytoh commented 3 months ago

main.zip

I manage to edit the script to directly replace that ${originalname} to include a requirement to remove spaces.

Sorry for this method because i'm not IT background, I only knew html and sql, currently learning js

The file attached is main.js in the plugin file.

wavetg commented 2 months ago

When there are spaces in the filename, the attachment is named in url encode, and I would like to be able to display the spaces properly

roytoh commented 2 months ago

When there are spaces in the filename, the attachment is named in url encode, and I would like to be able to display the spaces properly

Url not possible to have spaces if not mistaken. I'm self learn coder so theory i might not good. But as i saw website or url don't have spaces. So i think not possible to display space in url encode.

Do i get your question correct?

wavetg commented 2 months ago

When there are spaces in the filename, the attachment is named in url encode, and I would like to be able to display the spaces properly

Url not possible to have spaces if not mistaken. I'm self learn coder so theory i might not good. But as i saw website or url don't have spaces. So i think not possible to display space in url encode.

Do i get your question correct?

What I mean is that when inserting an image in an obisidian file, this plugin will automatically name it for me, and I want to use the current md filename as the name of the attachment, at this point, if there are spaces in the md filename, then there will be spaces in the name of the attachment in the form of url encode. For example, when the file name is Java scripts, when I use the filename variable as the name of the attachment, then the name of the attachment will be modified as Java%20scripts

trganda commented 2 months ago

I tested ${originalname.replace(/\s/g, '')}

But still can't remove space from original file name

There was no real expression language support in this plugin, it's just a replacement. So you can't use replace() in ${}, if you want to remove the space of your attach file, this plugin may not helping your.