[GIS] Set Relative Hyperlink to open windows explorer using Actions in QGIS

file pathhyperlinkqgis-2

I am wondering how to solve this problem I am having. I am trying to make an action in QGIS when I click on my feature, windows explorer will display the folder for that feature. I have the folder name in the attribute column, and an absolute path to the top level of the folder in the Actions.

I have looked up how to hyperlink in QGIS and have looked on the forums, but I have not been able to find a good solution to my questions. I have tried the eVis plugin and it is not a solution I am looking for. I want specifically windows explorer to open when using action on a feature, which is set using relative path.

I hope the screen capture shows up, but if not…
In Layer Properties – Feature|Actions, the Type is set to Windows, the name is Folder, the action is recorded as:
explorer C:\Users\Me\Desktop\TN\Test\Picture[%"Hyperlink"%]

How would I get the recorded action set to a relative path instead of an absolute path?

Best Answer

You can open a relative path. The path will be relative to the project's folder. If you want to check which is the project's folder path, just add an action with: explorer ., where . stands for the current folder.

To solve your problem, it dependes how do you store the relative path.

If your attribute values already starts with ., like .\GIS DataBase you simple add an action with:

explorer [% "PATH" %]

If your attribute values start with the folder or filename, simple add the string .\ before the actual path, like:

explorer ".\"[% "PATH" %]

Action to open relative path

Related Question