Search-Replace in external link reference?

My document has many image files inserted, via an external link which I can see when I click Edit…External Link. Each of these links has a form like this:

C:\buffer\Mendelsohn\filename.jpg

I don’t know how it got like this, but what I really want for each link is this:

C:\Mendelsohn\filename.jpg

Is there any way to take out the \buffer part with one search-replace, or do I have to go and modify each link manually?

You could extract the CONTENT.XML and there you check the images’ paths. This can be absolute or relative. Writer displays absolute paths even it is customized to use relative ones! So examine the CONTENT.XML (search some images and check the path).
Once the syntax of the paths is clear, you can proceed with


SEARCH

  • C:\buffer\Mendelsohn (or similar! Writer can use slashes instead of backslashes etc.)

REPLACE

  • C:\Mendelsohn (or similar!)

(Use Notepad++ or a similar editor for this operation.)


Example for relative path in Writer’s CONTENT.XML

href="../SO52photos/apples.jpg"

Steps of proceeding


On Windows you may rename Mendelsohn.odt to Mendelsohn.zip. Then extract the CONTENT.XML (and delete the remaining one in the container resp. ZIP file). After SEARCH&REPLACE insert the altered CONTENT.XML into the ZIP file, rename it to ODT file.

Be aware to work on a duplicate until your result is as wished.

LibreOffice always shows the whole path, although it is relative, depending on
Menu/Tools/Options/LibreOffice Load&Save/General - Save URLs relative to file system.

1 Like

Thanks for your reply. Unfortunately, I am not experienced enough to know how to extract content.xml from the document, so I am stymied at step one.

As it stands, the image paths are all wrong, at least according to the list that comes up with Edit…External Links; which is presumably why there are no images, only boxes which are clearly intended to contain images. (This is why I need to change the external link paths).

I am sorry that I do not know another way for mass renaming the paths. For your purpose you need:

  • a compression program (in-built in Windows)
    (it is possible to addionally install 7-zip or Win-Rar or onother one)
  • editor (recommended for Windows: Notepad++ - please download and install or use the portable version without installing)

After you have renamed Mendelsohn.odt to Mendelsohn.zip you can open this container file and you will see some different files and folders. If your window is not maximized you simply can drag/drop the CONTENT.XML into the opened folder or on the desktop.

When you have mastered this step then reply again… - Cheers

Saving as
image
no need the compression program, and any plain text file editor can be used to do the job.

1 Like

Thank you, that was a useful suggestion. I still couldn’t figure out how to fix the links, so I ended up doing it manually through Edit…External Links… and Modify manually for each one. I also had to Break link since many of them were duplicated. Thanks again to you and Grantier!