How can I move 1000+ images in a subfolder and then update their path?

What I’m trying to do

I imported a bunch of images from Bear when I migrated to Obsidian. Each image is under a subfolder of the images folder in the root.

For example:
images/image1/image1.png
images/image2/image2.png
images/image3/image3.png

How can I move all the images in batch and then also update their paths?

Things I have tried

I’ve found that the Obsidian app updates a path when I manually move images, but it takes too much time.

Does anyone have a better way to pull this off?

Thanks🙏

Easiest way is in File Explorer (if you’re using Windows).

Search for *.png, select all, cut (Ctrl+X), then paste (Ctrl+V) them into the /images folder.

You can then remove all of the folders.

The short answer: Carefully!

If you’ve already linked your images I would be a little wary off doing this outside of Obsidian as you might loose the links to those images. So even though it seems easy to do with an outside script or through the system file explorer, you could have an issue with all image links in that case.

Doing it through Obsidian would take more time, but it would/should preserve links.

If you’re not into coding, I would take a thorough look through the community plugins to see if there are some which might be useful to reorganise your links. Otherwise, I’d do it the slow and steady way through Obsidian, and be sure to backup your vault often during such big changes.

there is some plugin that does this

maybe two

but one at least works with markdown links only if i remember correctly

Thank you, everyone.

To share some insights for future reference, I’ve confirmed that a path updates even when using Finder (as @Markimus suggested), with a caveat. The tricky part arises when I have the same file name for images. The path won’t update correctly unless I manually move the images within the Obsidian app.

I appreciate @holroy’s advice to move files carefully, and that’s what I’ve been doing, but it’s somewhat cumbersome when I have more than 1,000 images.

Do you know which extensions might support what I’m trying to achieve?(@holroy @Yurcee ) I’ve searched for them, but haven’t found anything helpful so far.

Do your image links have the path in them (![[images/image1/image1.png]]) or just the filename (![[image1.png]])? Links containing paths will tend to break if you move the file from outside of Obsidian. Links without paths will continue working — but if more than 1 file has the same name, the results will be unpredictable because Obsidian can’t guess which one you mean.

Depending on what your image links are like, how often you encounter them, and your preferences, it may be worthwhile to just move the files and then fix broken links as you find them. (If you never encounter a particular link again, it doesn’t matter if it’s broken.)

2 Likes

Information on how the images are linked is missing here. As a general principle, links in Obsidian are by file name only. The files thus can be moved anywhere in the vault using an external file manager. Links will continue to work.

Obsidian will include links for disambiguation, i.e., if two files exist with the same name in different directories. In that case, moving the files outside of Obsidian will not preserve the links. One way to handle this is to mass search/replace the vault and change the path used in the links to the path where the files were moved, e.g. “search:” images/image1/; replace “/new/path/to/the/images/”. This can be done with external tools (an editor, the sed command in linux) or with an Obsidian plugin.

Preferably in Obsidian, you use unique descriptive file names for all your files in your vault, so location does not matter. Renaming a file in Obsidian will automatically update the paths (and likely will remove the path if the file name is unique). However, I do not see a way in which such rename operation could be automated.

2 Likes

this is it:

use a test vault with recommended settings first to see what the caveats are and if what it does is suitable

i have not used this so i don’t know what it does when you have wikilinks and whether you need search and replace attachment references first

i believe there is regex replace information on the forum on how to exchange wikilinks with markdown links

i second vanadium’s thoughts and advice: users should preferably use unique or descriptive image names and maybe even remove spaces from them

another:

some say this is less buggy?!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.