Re: Relative file paths for images



On 12/08/2010 12:03 PM, zoomer wrote:

Hi, is there a way to point to an image file with a relative path?

For example, instead of: "C:\my project\graphics\image.png"

I would like to use: "graphics\image.png"

In this example my .dia file would be located in C:\my project

Relative paths would be a huge help for me right now.  I have hundreds of
images in my diagram... but my file folder structure has changed so all
images appear broken.   I need to manually update the path of each image...
but if paths were relative I wouldn't have to do this.

Zoomer,

I am new here, but....

Dia files "filename.dia" are XML plain text files. They can be edited with a PLAIN text editor that does not add any formatting. For example, since you are talking about C:, you must be on Windoze, thus you could use Notepad.

First, make a backup copy of the file!!!!!!

Then open the file and search in it for some portion of the filename or pathname, or perhaps "png".

There you will see what Dia thinks the path is and how it is structured.

I don't know how it works on Windoze and I don't know what version of Dia you are using or if it works differently than the version I am using (either 0.97 or 0.98 -- I installed 0.98, but it is telling me it is 0.97 ... on LINUX).

On *MINE* it *IS* putting in relative pathnames to the images. But that is because I can go to a particular directory before I start Dia from the command line. I do not know if you have a command line method for starting Dia on Windoze. Thus on *MINE*, if I start Dia from a command line while I am in a MyDiaStuff directory and my images are in the same directory, the image information in the .dia file simply has just the image filename. However, if I am in /home/myname when I start Dia and then I import the image from /home/myname/MyDiaStuff, then the image information in the .dia file is "MyDiaStuff/filename.png"

If you don't solve the relative path problem, then you can either a) "simply" change the information in the .dia files; b) you can create links to the image directories on Windoze (can Windoze do that?); c) you can move the image directories to be where your files expect them to be (which you don't want to do).

If you have lots of documents, there are methods to make these kind of find/replace changes using a script (batch command file), but since I don't use modern Windoze, I don't know the name of the Windoze program used for that. But, with the right command you could change the paths in thousands of files all at once. (Just MAKE BACKUPS FIRST; it can be tricky because of the slash and backslash characters which may need to be escaped (protected)).

If you have just one diagram, then you could use the find/replace in a text editor like Notepad (to change the current absolute path to a different absolute path). The key, however, is to NOT use a text editor that changes or adds any formatting.

Jay



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]