About File Links and Relative Paths

Glossary  Return to Start  Previous  Next

 

Personal Knowbase provides 3 methods to link from articles in a Knowbase data file to external files or folders:

1.        Active links
2.        Hypertext links
3.        Attachments

 

Click the links above for more information on each of these types of links. In all cases, all references below to links to files also apply to links to folders.

 

In summary, an active link is part of the text of the article in which the path and name of the target file are explicit in the text itself, such as the text string file://"C:\Users\username\Documents\Personal Knowbase\my file.txt". The target is everything after the URL indicator file://.

 

A hypertext link is also embedded in the text of the article, but the target file is hidden behind an arbitrary piece of text. To show that it is a link, it appears green and underlined in the article's text in the Article Window. The target file name is shown in the link's Hypertext Link Properties Dialog Box.

 

Finally, attachment files are linked to an article without appearing in the article's text. An article's attachments are listed in the Attachments tab of the Article Properties Dialog Box.

 

Launching any of these links to files causes the target file to open in whichever Windows application is configured for that file type.

 

Absolute Paths

 

By default, article attachments, active links, and hypertext links to external file name targets use full absolute path names to exact file locations on your computer. If the target of a link is, for example, "C:\Users\username\Documents\Personal Knowbase\my file.txt", then the target file will only successfully launch from that exact location.

 

If the file is moved or deleted in Windows, then when you try to launch the link from Personal Knowbase, you will get an error message File or Folder Not Found from which you can Search for the file or Browse to manually fix the link.

 

Relative Paths

 

Alternatively, file names can be specified in a Target field without a complete absolute path name. If a full path name is not included in a file target, Personal Knowbase locates your linked files relative to another specified folder.

 

Examples of file link targets using incomplete relative paths are "my file.txt" and "Knowbase\image03.jpg". Note that the target could be just a file name or could be a partial path name with a file name.

 

Using relatives paths can be useful if you expect in the future to need to move your linked files or change their paths, such as when moving all your data files to a new computer or when using a mapped network drive. Your file links will continue to work, as long as their relative locations do not change, if you simply change the relative path specified.

 

Options

 

Personal Knowbase provides 3 options for how to locate targets for file links using relative paths. This setting applies to all links in a single data file and is set on the Articles tab of the File Properties Dialog Box with the setting for Location for Targets of Relative Links.

 

You can locate files relative to:

 

(1)   the default Attachments folder specified in the Preferences Dialog Box,

(2)   the main data file's location, or

(3)   an arbitrary specified path.

 

Example

 

Say that your default Attachments folder is "D:\docs".
Your current data file is "D:\projects\writing.kno".
And for the arbitrary path, you specify "D:\archive\".

 

In case (1), you set the Location for Targets of Relative Links to use the default Attachments folder. Then the target "my file.txt" will be located at "D:\docs\my file.txt". The target "Knowbase\image03.jpg" will be located at "D:\docs\Knowbase\image03.jpg".

 

In case (2), you set the Location for Targets of Relative Links to use the data file's location. Then the target "my file.txt" will be located at "D:\projects\my file.txt". The target "Knowbase\image03.jpg" will be located at "D:\projects\Knowbase\image03.jpg".

 

In case (3), you set the Location for Targets of Relative Links to use the arbitrary path you specified. Then the target "my file.txt" will be located at "D:\archive\my file.txt". The target "Knowbase\image03.jpg" will be located at "D:\archive\Knowbase\image03.jpg".

 

Note for portable installations:  The option using an arbitrary specified path always uses an exact folder. If you are running Personal Knowbase from a portable device, this option will not adjust to be relative to the portable drive. When using relative paths in conjunction with portable drives, we recommend using one of the other two options for locating relative links.

 

Note for exporting to KNO files:  Since File Properties are not exported when you export articles to another KNO file, this option is not exported. Remember to set this property in new KNO files to avoid broken links.

 

 

Storing Incomplete Targets

 

To cause a link use a relative path, you must store an incomplete file name target for the link.

 

When creating either hypertext links or attachments, if you use the Browse button to select the Target, the absolute path and file name is inserted in the Target field.

 

Alternatively, you can type an incomplete file name into the Target field or edit the Target to omit the full path name.

 

For each article, you can set an article property to automatically omit the full path name whenever the path is equal to the currently set relative path. You can set this setting from the Attachments tab of the Article Properties Dialog Box or from any Hypertext Link Properties Dialog Box for a link in this article. To omit full path names for links for this article, uncheck the checkbox labeled Save full pathnames for new file or folder targets.

 

In the example above, for case (1), if this setting is unchecked and you select the Target file "D:\docs\my file.txt", only the target "my file.txt" is stored. If the checkbox is checked, the absolute path name "D:\docs\my file.txt" is stored.

 

On the Articles tab of the File Properties Dialog Box, you can set the Save full pathnames for new file or folder targets option at the file level to change the default for this setting for all new articles created in this data file.

 

 

NOTE:Use relative links with caution and planning, since changing your option for locating relative links can break every incomplete file link in your data file.

 

 

For more information about using relative link paths, see these Procedures:

Linking to Files Relative to the Data File's Location

Linking to Files Relative to an Arbitrary Folder