When doing things with the images in a vault it is more difficult because the image names have spaces in them. The main reason for this is that the images are stored with spaces but in the notes you have to use %20 to refer to these spaces.
I tried to make a program to move files around the %20 just makes it more complicated.
Proposed solution
Replace the spaces in the autogenerated name with -.
Current workaround (optional)
Right now I am using regexes like this to deal with spaces and just renaming it myself to -.
import re
image_with_spaces_pattern = re.compile(r'(!\[.+]\([.\\/A-z0-9]+)(%20)([A-z 0-9.%]+\))')
while re.search(image_with_spaces_pattern, text):
text = re.sub(image_with_spaces_pattern, r'\1-\3', text)
I don’t understand what you mean. I am just talking about the name obsidian generates when you paste an image into a note in the vault. They are usually PASTED IMAGE DATE I think it would be better if these names are seperated with - or _ instead of spaces as the spaces are turned into %20 and the _ and - just stay the same.
When I paste a screenshot into a document, there are spaces in the image name, such as: '! [[Pasted image xxx.png]]`
Whenever I want to upload an image to my image hosting, I usually need to change the image name to remove the spaces
Proposed solution
The spaces in the image name are replaced by -, i.e. ! [[Pasted image xxx.png]] → ! [[Pasted-image-xxx.png]]
The Shortcuts gallery on macOS has a ‘Rename Files’ shortcut that can find spaces and replace them with hyphens, underscores, etc. Works on multiple files at once. I use it all the time for the reasons you outlined in the first post.
Another easy solution is to create a simple Automator ‘Folder Action’ to change spaces in file names to underscores (or hyphens). Any file that is dropped into the specified folder will automatically be renamed. You can then drop files into Obsidian. Also useful if you want to rename files that aren’t going to be used in Obsidian.
I think @anon63144152 said that you have to drop into a (non-Obsidian) folder first. Once it’s renamed by Automator, you can then drop the files into Obsidian.