Is there a way to replace the path for an image linked to a file?

A coauthor and I are getting really schooled about trying to both edit a Scrivener book project. Among the many issues is the problem of paths to images that are linked via Insert…Image Linked to File… The problem is that the links are absolute. Thus, userA and userB share a Dropbox folder with images and userA inserts a link to one; when userB views the project, instead of the image they see an error:

MISSING_IMAGE:/Users/userA/Dropbox/Figures/Ch 12/fred.png

The image is right there in Dropbox for userB, same path except that “userA” is “userB”. There have been requests that these paths be relative rather than absolute, which would(might) solve the problem. However, userB could fix the problem if they could just globally replace “userA” with “userB” in the paths. Is there a way to do this?

What if instead, in this specific situation, you’d insert the image directly into the editor ? No link.

Inserting images directly will show the images, but there are two downsides. First is that this is a big project–the current chapter has 70 images in it alone. So we’d have to do a lot of downsampling (folder holding the linked images for this chapter is 123 MB at the moment). The other problem is that updates to the figures will not show up unless a fresh copy is inserted. With linking, changes to the figures automatically show up in Scrivener when the project is reopened.

Use a system of shortcuts and replacement rules something like the one I use, with a rule for each user. Each of you only will need to activate the corresponding rule before Compile and deactivate the other.

Managing images

Have a look at the user manual PDF, in the following sections:

  • §15.6.4, under subheading Fixing Broken Links. Basically, the fact that you can see this “MISSING_IMAGE” text in the editor is very much on purpose, and very much functional. Change it. :slight_smile: Use project replace to change them all. Create a saved search collection that scans for “MISSING_IMAGE” if you’re in a scenario where this can happen often.
  • While there, review the previous section, Links on Multiple Devices. True relative linking is not technically possible with the technology we use, but we have built a hybrid of sorts. It does mean having to following some structural guidelines for how you organise a project with its support files though.

Lastly, if you have administrative access to the machine, you can also use symbolic links in the /Users folder to create a UserB directory that points to UserA. All absolute links in your user folder will now work on both machines, so long as the directory structures are the same within them.

This is the method that I used myself back when I had this issue of differing account names.

1 Like

Well, that was easy. Doing a Project Replace on the broken paths works. Thanks! For others with this question, example below. But before that, a symlink question. I tried the following in Terminal:

ln -s /Users/userB/Dropbox/Figures /Users/userA/Dropbox/Book/Figures

But that did not fix the broken links. What am I doing wrong?

EXAMPLE of fixing broken links

My link to the folder holding figures is of this form:

/Users/userA/Dropbox/Book/Figures whereas my coauthor’s is /Users/userB/Dropbox/Figures

I Project-Replaced the latter with the former, and upon closing and reopening the project, the links were fixed.

1 Like

Well firstly, to make another route to your user folder through an alternate “user folder” you would only want a symlink pointing to user folder A from user folder B (or however which way)—exactly like I demonstrated in the linked thread. The only part of the path that should be different is the user account folder name. Fix that, and everything else comes along free for the ride. You do not have to make thousands of sym links for every folder. All you need is one at the very top, to fix every single link.

As for what you tried specifically, that might not work so well, as Dropbox doesn’t officially support symbolic links inside the sync area. As I recall they can work for a bit, but they don’t sync as links is the problem, and become regular files.

What works better is to put the symlink outside of the sync area entirely, and pointing to it. So for example you could do something like this in a subfolder that you create in Documents:

ln -s ~/Dropbox/Figures Figures

I can’t say for sure though because I don’t know the complete disposition of everything on both drives. Overall I think it would work better to make sure paths are the same everywhere (below the account name). I don’t quite understand why on one machine your Dropbox path is Books/Figures but on the other machine it is just Figures, for instance. Shouldn’t everything below the Dropbox folder level be identical on both machines?