16

I have about 30 different QGIS Project files for 30 different clients. Each is saved onto my computer and all their relevant vector and raster files are all saved locally.

We are now in the process of moving office and upgrading our computers.

As a result, I need to move all my files from my computer onto the network drive, thus destroying any previous file references.

Aside from manually clicking on each file and looking for each ones new location, is there any other way around this.

(Each project could have a few hundred links to update)

0

4 Answers 4

21

I'm not sure what version of QGIS you are using, however in v>2.0.1 you may use the "Handle bad layers" dialog like this:

enter image description here

  1. Select all layers in common directory while holding Ctrl key
  2. Double click on last one you select
  3. Re-path one of the layers and select Open
  4. Repeat process for additional directories

This will batch update file based layers by directory (not database layers):

enter image description here

5
  • 1
    Thanks for pointing this out! I've been looking for a feature like this since ArcGIS added the Repair datasource option a few versions ago. Commented Nov 13, 2013 at 14:43
  • I didn't know you could update multiple layers with a common directory at once. Thanks!
    – SAnderka
    Commented Nov 13, 2013 at 15:45
  • Cheers! this seems to be what i am looking for. I have not tried it yet but will do today. if it works i will acept the answer.
    – Ger
    Commented Nov 14, 2013 at 11:38
  • It is nice but it doesn't seem to be able to work with file geodatabases as it only wants a file not a directory. As a test I tried to see if one of the arcane named gdb files might work but after trying most I gave up.
    – John
    Commented Nov 19, 2013 at 20:48
  • This doesn't seem to work for me with QGIS 3.2 on macOS. I've tried both the command key and shift key for selecting multiple files, but it doesn't seem to manually edit multiple files when I change one path. Commented Aug 29, 2018 at 21:57
20

The QGIS project files are simple text files. You can search and replace the content with any text editor.

Just look up how the files are referenced in the old and new storage location, and you know what has to be changed.

Notepad++ allows even for batch processing across several files in one step.

2
  • 4
    Tried this with QGIS 3.2 on macOS and it looks like the project files are now binary files, so this solution no longer works. Commented Aug 29, 2018 at 21:58
  • 4
    @AdamStewart the .qgz files are just zipped versions of the .qgs files. You can unzip them inside your OS, or choose to save as .qgs files as it was in QGIS 2.
    – AndreJ
    Commented Aug 31, 2018 at 9:30
7

If you save the project with relative path links before you move your data you shouldn't need to fix any links in the new projects.

In QGIS v2.01 Go to Project > Project Properties and select Save Paths Relative before you move your data across, then as long as you are just copying the data across and retain the same folder structure the files should work when you reopen the projects from your network drive.

Saving relative paths

4
  • Unfortunately the first bit of the structure will be different at the very least.
    – Ger
    Commented Nov 14, 2013 at 11:39
  • OK, relative paths will still work as long as the projects and data are saved in the same structure relative to each other even if the first part changes. In the example below as long as you move and keep everything below the Work folder level the same the initial part of the path can be as different as you want. Projects = C:/Work/Projects/myproj.qgs and Data = C:/Work/Data/myfile.shp
    – MAJ742
    Commented Nov 14, 2013 at 11:56
  • Accepted it is just the C:// wil have completly changed to a networked drive.
    – Ger
    Commented Nov 15, 2013 at 12:32
  • I may have found the solution for the relative path problem. I hope the QGIS team can check and solve this problem. See my post here: gis.stackexchange.com/questions/210992/…
    – oat
    Commented Oct 17, 2016 at 5:18
2

I found a nice Plugin that could be of use: Qconsolidate (to install: in plugin settings first check the box "experimental plugins"). This plugin saves all layers in the project to one folder and edits the pathways. Folder and project can be moved and opened from anywhere.

3
  • Qconsolidate imho solves a different problem. It creates copies of the datasets instead of changing the paths to a new network drive location.
    – underdark
    Commented Jul 27, 2016 at 13:30
  • This is correct. If you work with very many large shapefiles in multiple projects it is not very useful. However if you work with few workspaces with a large amount of shapefiles located in many different maps it is nice to have an easy way to group and backup them. Commented Oct 5, 2016 at 13:35
  • QPackage does a similar trick, for info.
    – gisnside
    Commented Apr 30, 2018 at 12:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.