2

I am searching for an expression or some assistance in changing filepaths and links to photos within attributes to relative paths.

I have used QConsolidate to create a folder with all the files and links I want.

I would like to create a single folder so I can give the folder to a client and when they install on their system they will have all the connections retained.

I have been finding info on relative paths and thought I had cracked it with @project_folder ||'/data/'|| filename

But this expression does not change the file path when the folder is moved to a different location.

Maxima
1,6999 silver badges18 bronze badges
asked Jul 9, 2018 at 8:01

2 Answers 2

1

Presumably you're using that expression to store the file path in a field. However, a regular field won't update automatically. The solution is to use either a virtual field or a default field value. In this case, I expect the default field value update will not be triggered when the @project_folder value changes, so you will be better off with a virtual field.

To create a virtual field, use the Field Calculator to create a new field with your expression, and check the option to "create virtual field"

@project_folder ||'/data/'|| filename

In this expression, filename must be the name of a field in the same layer.

enter image description here

answered Dec 17, 2019 at 19:16
0

The plugin QConsolidate works by me. (tested on QGIS 2.18.21)

Maybe, before export you have to configure the project: Menu Project - Properties - General - Save paths as "relative".

After using the plugin, if you open your project file with a text editor (i.e notepad ++), you see the paths are relative between the balises <datasource>./layers/xx.shp</datasource>

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Jul 9, 2018 at 9:14
2
  • Thanks. I did try QConsolidate but didn't look at the project file after export. Will check again but not sure if this impacts the filepaths in the attribute table which link to geotag imagery. Would you happen to know the script fro paths in a field. Like I said I used ---@project_folder ||'/data/'|| filename--- but the path doesn't change when folder moved. I am thinking this script is close to what I need. Thanks again Commented Jul 10, 2018 at 0:39
  • Have you tri to add a virtual field and this code -- @project_folder ||char(92) || 'data'||char(92) || 'filename' -- Commented Jul 11, 2018 at 9:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.